For this program, you will write a GUI (Graphical User Interface)-based Calculator that can evaluate simple binary expressions. The user will enter an expression of the form
operand1 operator operand2
into the text field of a dialog box (shown below), where the operands and the operator are separated by spaces. For example, to add 2 and 3, the user would enter
2 + 3
The class "GUICalculator.java" is provided for you. The program, as given, creates a dialog box that takes input from the user and stores it in the local variable "inputString". A second local variable, "outputString", which you will use for your output, contains the output that will be written to screen in a message box as shown below. Requirements on your implementation and output are described below.
Design and create a class called "Expression" that will contain methods and possibly instance variables to aid you in processing and evaluating the input. At the very LEAST, your Expression class must divide the task of evaluating the input into the following sub-tasks, each of which must be implemented by at least one method
Once you have completed your Expression class, add code to "GUICalculator.java" (where indicated by the comment //YOUR CODE & METHOD CALLS HERE) that uses your Expression class to process the input and produce the correct output.
Your code must check for the following error conditions
In the case of valid input, your program should output the initial expression entered by the user followed by an equals sign and then the result as shown in the figure above.
In the case of invalid input, your program should output an error message that is specific to the type of error encountered, e.g. "Divide by Zero".
For this assignment you will need to create a Jar file that contains the source code for Expression.java AND GUICalculator.java that you edited
as part of this assignment. Follow these instructions for creating a Jar file.
The Jar file you submit must be named yourlastname_pro4.jar, where yourlastname is your last name.