Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

2. How were various roles filled?

Answered: 1 week ago