Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java Program that can read from a file and translate mathematical expressions line by line. All code must be written in the 'Main'

Write a Java Program that can read from a file and translate 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.
For each input line, you will print to the display:
"Result of Line [lineNumber]: [result]"
Result of line 1:3
Result of line 2:7
Result of line 3:13
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
Result of Line 2: -4
Result of Line 3: Error: / by zero
Result of Line 4: 5
Result of Line 5: 160
Result of Line 6: No operator a ai 3
Result of Line 7: Non-integer input on this Line
[-"-jGRASP exec: java PolishMotationCalculator
Enter input file name: math3.txt
Result of Line 1: 2
Result of Line 2: 12
Result of Line 3: -1
Result of Line 4: 4
Result of Line 5: a
Result of Line 6: 3
Result of Line 7: 1
[ L--jgasp: operation complete.
[---jGRasp exec: java PolishwotationCalculator
Enter input file name: math4.txt
Result of Line 1: Non-integer input an this Line
Result of Line 2: 1
Result of Line 3: 1
Result of Line 4: Non-integer input on this Line
[.-jGRASP: operation complete.
...-jGRASP exec: java PolishNlotationCalculator
Enter input file nare: math5.txt
Resule of Line 1: 2
Result of Line 2: Non-integer input on this Line
Result of Line 3: -4
Result of line 4: Error: / by zero
Result of Line 5: -13
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

1.Which are projected Teaching aids in advance learning system?

Answered: 1 week ago