Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Data Structure Expert

Objectives:

To gain experience with stacks.

Documentation:
1. Explain the purpose of the program as detail as possible
2. Develop a solution for the problem and mention algorithms to be used
3. List data structures to be used in solution.
4. Give a description of how to use the program and expected input/output
5. Explain the purpose of each class you develop in the program.

Programming:
1. For each method, give the pre and post conditions and invariant, if any
2. Program execution according to the requirements given
3. Naming of program as required
4. Print out of source code

Description of Program

You are to write a program name calc.java that evaluates an infix expression entered by the user. The expression may contain the following tokens:
(1) Integer constants (a series of decimal digits).
(2) x (representing a value to be supplied later).
(4) Binary operators (+, -, *, / and %).
(5) Parentheses

Spaces between tokens are allowed but not required. The program will convert the (user input) infix expression to postfix (RPN) form and display the converted expression on the screen.

The following example illustrates the behavior of the program (user input is in bold and red):

Porgram output is in bold and green.

Enter infix expression: (7 + x) * (8 - 2) / 4 + (x + 2)
Converted expression: 7 x + 8 2 - * 4 / x 2 + +
Enter a value for x: 5
The result is: 25

Enter a value for x: 8
The result is: 36

Enter a value for x: 3
The result is: 20

Enter a value for x: q ------>Any value that is not an integer - the program terminates

When solving the postfix expression, you must prompt the user for an input value for x, solve the expression and return a result. You must use an operand stack to process the postfix expression.


Attachment:- Java-Stacks.docx

Data Structure, Computer Science

  • Category:- Data Structure
  • Reference No.:- M9892663
  • Price:- $60

Priced at Now at $60, Verified Solution

Have any Question?


Related Questions in Data Structure

Problem regarding the management program

Problem: Looks like its just adding a save and load feature to the same file you sent me for python 3.5 Until now, you have had to leave your team management program running on your computer indefinitely since you did no ...

Data Communication Delivering Information anywhere

Topic: Data Communication Delivering Information anywhere. Write a 9-12 pages paper in which you: Present an overview of the origin and history of the concept. Describe the current use of and attitude toward the concept. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As