10 Apr Equation Evaluator Project
Create a Program that will accept an equation as input from the user using standard algebraic format.
Examples:
N O N (ENTER)
(N O N) O N (ENTER)
( ( ( N O N O N ) O N O ( N O N ) O N ) O N ) O N (ENTER)
where N is a number and O is either a math or logical comparison operator. The entire entry must be entered as a single input with one enter key click.
The Math operators that must be accepted are:
+ addition
– subtraction
* multiplication
/ division
% modulus
The comparison operators are:
== equals
!= not equals
@= absolute value of both are equal
< less than
<= less than or equals
> greater than
>= greater than or equals
NOTE: You are not required to include comparisons of equations. You may limit comparisons to just 2 numbers.
The use of math operators will cause the resulting number to be displayed.
The use of a comparison will cause “True” of “False” to be displayed.
Allow the user to repeat the inputting of expressions as many times as they would like. The program must not fail due to improper user input, so, you must catch error exceptions and handle them.
NOTE: I suggest that you use the algorithm in the attached Word document as your basic equation parsing algorithm. You must use two stacks, based on the Stack ADT, to parse the user inputted equation.
Include your algorithms, and other appropriate documentation in your code. Include UMLs for any classes that you use to create objects.
—————————————————————————-
1. While there are still tokens to be read in,
1.1 Get the next token.
1.2 If the token is:
1.2.1 A number: push it onto the value stack.
1.2.2 A variable: get its value, and push onto the value stack.
1.2.3 A left parenthesis: push it onto the operator stack.
1.2.4 A right parenthesis:
1 While the thing on top of the operator stack is not a
left parenthesis,
1 Pop the operator from the operator stack.
2 Pop the value stack twice, getting two operands.
3 Apply the operator to the operands, in the correct order.
4 Push the result onto the value stack.
2 Pop the left parenthesis from the operator stack, and discard it.
1.2.5 An operator (call it thisOp):
1 While the operator stack is not empty, and the top thing on the
operator stack has the same or greater precedence as thisOp,
1 Pop the operator from the operator stack.
2 Pop the value stack twice, getting two operands.
3 Apply the operator to the operands, in the correct order.
4 Push the result onto the value stack.
2 Push thisOp onto the operator stack.
2. While the operator stack is not empty,
1 Pop the operator from the operator stack.
2 Pop the value stack twice, getting two operands.
3 Apply the operator to the operands, in the correct order.
4 Push the result onto the value stack.
3. At this point the operator stack should be empty, and the value
stack should have only one value in it, which is the final result.
Website(s) Published To
Search
Id Website Action
No results found
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Wridemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.