Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

Hi, you have helped me on a project recently.

Hi, you have helped me on a project recently. I have uploaded the

code and would like your help in further development on the program to make it functional. + button to add two numbers together, – button to perform subtraction, x button for multiplication function, / for division so two number could be divided and could also tell the user that they cannot divide by zero if they try to input that. Whole number is fine, I don’t need to make this work for decimals. Also, I have a couple of question for you to answer.

– Write up, or explanation on your approach. This could be a paragraph, or two on this.
-What are the lesson learned on this
-Write up on ways to improve your code. Improvement could be something you would have done different, but was not able to do because the scope, or time did not permit, functions that you were not able to implement and the reason for not doing, a different approach that you would have taken a different way of solving the problem etc. This could be a paragraph, or two on this.

import java.awt.Component;import java.awt.FlowLayout;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import java.io.FileNotFoundException;import java.util.ArrayList;import java.util.Scanner;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;public class GenerateGUI {private static Scanner scanner;private static File txtfile;private static JTextField textField;private static String getLabel(String line) {int counter;line.trim();for (counter = 0; counter < line.length(); counter++) {if (!Character.isAlphabetic(line.charAt(counter))) {break;}}return line.substring(0, counter);}public static void main(String[] args) {String str , label;String fileName =”ProperInput.txt”;try {txtfile = new File(fileName);scanner = new Scanner(txtfile);if (scanner.hasNextLine()) {str = scanner.nextLine().trim();label = getLabel(str);if (!label.equalsIgnoreCase(“Window”)) {System.out.println(“First label should be WINDOW”);return;}str = str.substring(label.length()).trim();JFrame frame = (JFrame) addComponentRecursively(str, label);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);} else {System.out.println(“Unknown Error”);}} catch (FileNotFoundException e) {
Background image of page 1
JOptionPane.showMessageDialog(null, fileName + ” file not found”);return;// e.printStackTrace();} catch (Exception exception) {System.out.println(“Unknown Error”);exception.printStackTrace();}}private static ArrayList<Integer> getIntegerArray(String str)throws Exception {int i, j;ArrayList<Integer> result = new ArrayList<>();for (i = 0; i < str.length(); i++) {for (j = i; j < str.length() && Character.isDigit(str.charAt(j)); j++);if (i != j) {result.add(Integer.parseInt(str.substring(i, j)));}i = j;}return result;}private static Component addComponentRecursively(String str, String label)throws Exception {String temp;if (label.equalsIgnoreCase(“Window”)) {str = str.trim();JFrame frame;if (str.charAt(0) == ‘”‘) {str = str.substring(1);temp = str.substring(0, str.indexOf(‘\”‘));frame = new JFrame(temp);str = str.substring(str.indexOf(‘”‘) + 1).trim();} else {frame = new JFrame(“Default title”);}if (str.charAt(0) == ‘(‘) {temp = str.substring(0, str.indexOf(‘)’) + 1);str = str.substring(temp.length()).trim();ArrayList<Integer> ints = getIntegerArray(temp);if (ints.size() == 2) {frame.setSize(ints.get(0), ints.get(1));}}temp = getLabel(str);str = str.substring(temp.length()).trim();JPanel p = new JPanel();if (temp.equalsIgnoreCase(“Layout”)) {temp = getLabel(str);str = str.substring(temp.length()).trim();if (temp.equalsIgnoreCase(“flow”)) {FlowLayout fl = new FlowLayout();p.setLayout(fl);}if (temp.equalsIgnoreCase(“grid”)) {if (str.charAt(0) == ‘(‘) {
Background image of page 2

Show 

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"