Develop a solution for the problem and mention algorithms

Assignment Help Data Structure & Algorithms
Reference no: EM13313351

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

Reference no: EM13313351

Questions Cloud

Universal ethical egoism is inconsistent or incoherent : What do you think of the argument that universal ethical egoism is inconsistent or incoherent? Do you perceive an internal contradiction in the idea of “group self-interest” in contrast to individual self-interest? Provide an example that helps expla..
Explain saturated calomel electrode : Saturated Calomel Electrode || Titration Solution | Ag (s) Calomel Electrode: E=0.241V For Ag+ + e- ---> Ag(s), E0 = 0.79993 V. AgI is Ksp = 8.3 × 10-17. What it the volts at equivalence point when Ve=30.00mL
Determine the electric field at the electron : Type your question hereA uniform line of charge that is 5.00cm long has a total charge of 6.00uC. What is the electric field (given in magnitude and direction) at the electron
Find length and width of square basin for virus disinfection : Find the length and width of a square basin for virus disinfection of a flow of 6 MGD. You may assume a depth of 5 ft, a C(dot)t product of 10 (mg/L) (dot)min for 1.5-log removal, and a target free chlorine residual of 0.6 mg/L.
Develop a solution for the problem and mention algorithms : 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.
Find probability that vehicle pulling out will get accident : The driver of the vehicle does not look for oncoming traffic. Road conditions and vehicle speeds on the highway are such that it takes 1.5 seconds for an oncoming vehicle to stop once breaks are applied.
Compute the amount naoh that is acetic acid : Calculate the amount (in mL) of a 1.520M NaOH that is required to add the following acetic acid solutions to prepare a buffer with the corresponding pH: pKa of acetic acid = 4.74
With what speed is the kereru travelling after the collision : a kereru new zealand wood pigeon travelling at 1.5 m/s due west has an elastic collision with an airbus a380 aeroplane. with what speed is the kereru travelling after the collision?
What is product positioning : What is product positioning? Product repositioning? Why and when would Rollerblade need to reposition?

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Write algorithm to create job applicant report

Write the algorithm to create job applicant report. Input consists of a series of records that contain the Social Security number or equivalent, last name, first name, middle initial.

  Determine complete list of nodes which ancestor

Let the following tree: tree a. Determine the children of Q? b. What is the complete list of nodes which have D as ancestor? c. Determine the height of this tree (as height is defined in text)?

  Linear-time algorithm to find odd-length cycle in graph

Give a linear-time algorithm to find an odd-length cycle in a directed graph. You may not suppose that graph is strongly connected.

  Determine expected number of collisions use hash function

Assume we use hash function h to hash n distinct keys into the array T of length m. Suppose simple uniform hashing, determine the expected number of collisions?

  An algorithm that will sort a with a worst-case runtime

Let A be an array with n elements such that the first n -sqrt( n) elements are already sorted (though we know nothing about the remaining elements). Give an algorithm that will sort A with a worst-case runtime substantially better than O(n logn).

  Implement a nice graph datastructure

Implement a nice graph datastructure. Implement two different greedy graph coloring algorithms. Shortest path algorithm and MST algorithms.

  Characteristics of quicksort

familiarize  with the performance characteristics of Quicksort under normal and worst case conditions. The assignment will require some programming and interpretation of the results.

  Determine the benefits of data mining to the businesses

Determine the benefits of data mining to the businesses when employing - Predictive analytics to understand the behavior of customers

  Define wan and provide an example of typical wan setup

Define a WAN and provide an example of a typical WAN setup and describe the components. Provide a picture, chart, or image if possible.

  Creating dataflow diagram

Think about the level of detail involved with creating a dataflow diagram, why should the narrative be prepared? Explain why do we need the questionnaire?

  What are entity-relationship diagrams

What are entity-relationship diagrams, and how are they used? Discuss the ethical issues to consider when planning a database.

  Find fraction of time during which queue grows

Suppose now there are three users. Find the probability that at a given time, all three users are transmitting simultaneously. Find the fraction of time during which the queue grows.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd