Question: Write a Java Program ( named PolishNotationCalculator ) that prompts the user for a file, reads from it , and translates mathematical expressions line by
Write a Java Program named PolishNotationCalculator that prompts the user for a file, reads from it and translates mathematical expressions line by line. All code must be written in the 'Main' method and you must not use Arrays or anything learned outside of class.
The code must incline comments that explain what is happening on specific lines.
You must use printffor printing results.
for addition
for subtraction
for multiplication
for division
to add to the result of the previous line to this line
to subtract from the result of the previous line to this line
to multiply the result of the previous line to this line
to divide the previous line by the result
The Errors:
For error handling, you should use any form of if conditions to check values.
If a line starts with anything that is not an acceptable operators, a message
No operator needs to be printed followed by the line as No operator the line
Ex: line of mathtxt
Result of Line : No operator
If a line starts with a operator, and there was an error in the previous line, the value of zero should be used as the result of the previous line
Example of line of mathtxt
Result of Line :
The above result are generated from:
If there is a noninteger value found in the file you can use the hasNextInt method to check this instead of printing the total, print Noninteger input on this Line
Example of line of mathtxt
Result of Line : Nonintegret input on this Line
The program should ignore the rest of the line, but keep performing calculations on the remainder of the file
There could be an arithmetic error division by zero you should display: Error: by zero
Example for line of mathtxt:
The program should ignore the result of this line, but keep performing calculations on the remainder of the file.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
