Question
Please create a program in java for evaluating arithmetic expressions in postfix (reverse Polish) notation. Design Specifications : - create a java project project5 and
Please create a program in java for evaluating arithmetic expressions in postfix (reverse Polish) notation.
Design Specifications:
- create a java project project5 and a package 5.
- read your postfix expression from a file expression.txt using the Scanner class. The numbers in the expression should be double values.
- Use the java.util.Stack class(http://download.oracle.com/javase/1.5.0/docs/api/java/util/Stack.html).
- Accept the following operations: +, -, *, /.
- Make sure that you do not divide by 0.
- Make sure that your stack is empty after evaluating the expression.
- Output should be to standard output.
- Create and implement a driver class.
Sample Output:
5 9 8 + 4 6 * * 7 + * = 2075.
Rubric:
- Input
a) Project reads expression files.
b) Project correctly recognizes numbers as double.
c) Project correctly recognizes arithmetic operators.
- Output
a) Calculations return the correct answer.
b) Program handles division by 0.
c) Program returns error for too many operators.
d) Program returns error for too many operands.
- Calculations and Implementation
a) Addition.
b) Subtraction.
c) Multiplication.
d) Division.
e) Use of Stack
f) Use of scanner class
Thank you for your help!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started