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 printf()for 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 1 of math7.txt
Result of Line 1: No operator 1+23
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 2 of math7.txt
Result of Line 2: -4
The above result are generated from: 0-1-3=-4
If there is a non-integer value found in the file (you can use the .hasNextInt() method to check this), instead of printing the total, print Non-integer input on this Line.
Example of line 1 of math4.txt
Result of Line 1: Non-integret 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 4 of math5.txt:
The program should ignore the result of this line, but keep performing calculations on the remainder of the file.
 Write a Java Program (named PolishNotationCalculator) that prompts the user for

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!