Starting from:
$35

$29

Project 1 Solution

The first programming project involves writing a program that evaluates infix expressions of unsigned integers using two stacks. The program should consist of three classes. The main class should create a GUI that allows the user input an infix expression and displays the result. The GUI should look as follows:








































The GUI must be generated by code that you write. You may not use a drag-and-drop GUI generator.




The second class should contain the code to perform the infix expression evaluation. The pseudocode for performing that evaluation is shown below:




tokenize the string containing the expression while there are more tokens




get the next token




if it is an operand




push it onto the operand stack else if it is a left parenthesis




push it onto the operator stack else if it is a right parenthesis




while top of the operator stack not a left parenthesis pop two operands and an operator




perform the calculation




push the result onto the operand stack else if it is an operator




while the operator stack is not empty and




the operator at the top of the stack has higher or the same precedence than the current operator pop two operands and perform the calculation push the result onto the operand stack




push the current operator on the operators stack while the operator stack is not empty




pop two operands and an operator




perform the calculation




push the result onto the operand stack




the final result is a the top of the operand stack




1

Be sure to add any additional methods needed to eliminate any duplication of code.




Your program is only expected to perform correctly on syntactically correct infix expressions that contain integer operands and the four arithmetic operators + - * /. It should not, however, require spaces between tokens. The usual precedence rules apply. The division performed should be integer division. A check should be made for division by zero. Should the expression contain division by zero, a checked exception DivideByZero should be thrown by the method that performs the evaluation and caught in the main class, where a JOptionPane window should be displayed containing an error message.




You are to submit two files.




The first is a .zip file that contains all the source code for the project, which includes any code that was provided. The .zip file should contain only source code and nothing else, which means only the .java files. If you elect to use a package the .java files should be in a folder whose name is the package name.



The second is a Word document (PDF or RTF is also acceptable) that contains the documentation for the project, which should include the following:



A UML class diagram that includes all classes you wrote. Do not include predefined classes. You need only include the class name for each individual class, not the variables or methods



A test plan that includes test cases that you have created indicating what aspects of the program each one is testing



A short paragraph on lessons learned from the project



Grading Rubric:






Criteria


Meets


Does Not Meet






5 points


0 points


















GUI is hand coded and matches


GUI is generated by a GUI






required design (1)


generator or does not match










required design (0)


Design


Supplied algorithm is used (1)


Supplied algorithm is not used (0)






Code duplication is eliminated (1)


Contains duplicated code (0)


















Contains separate class for


Does not contain separate class






expression evaluation (1)


for expression evaluation (0)






Contains checked exception class (1)


Does not contain checked










exception class (0)


















10 points


0 points














Functionality


Produces correct value for all


Does not produce correct value




operators(3)


for some operators (0)


























Correctly parses expressions without


Does not correctly parse






space delimiters (2)


expressions without space






2





delimiters (0)








Correctly implements precedence
Does not correctly implement


(2)
precedence (0)








Correctly evaluates parenthesized
Does not correctly evaluate


expressions (2)
parenthesized expressions (0)








Detects division by zero (1)
Does not detect division by zero




(0)


5 points
0 points








All operators included in test cases
Some operators not included in


(1)
test cases (0)








Test cases include expressions
Test cases don't include
Test Cases
without spaces (1)
expressions without spaces (0)




Test cases include cases to test
Test cases do not include cases to




precedence (1)
test precedence (0)








Test cases include cases with
Test cases do not include cases


parentheses (1)
with parentheses (0)








Test cases include a case to test
Test cases do not include a case


division by zero (1)
to test division by zero (0)








5 points
0 points








Correct UML diagram included (2)
Correct UML diagram not
Documentation


included (0)
Lessons learned included (2)
Lessons learned not included (0)










Comment blocks with class
Comment blocks with class


description included with each class
description not included with


(1)
each class (0)






Overall Score
Meets
Does not meet




16 or more
0-15




































































3

More products