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 object as stack.

f) Use of scanner class

Thank you for your help!

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!