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

  Why knapsack problem known as zero-one knapsack problem

Why Knapsack Problem explained as 0/1 Knapsack Problem. Skecth Dynamic Programming Tables (one for calculating optimal value and one for keeping track of items used.

  Representation of linked list

The table given below gives portion of a linked list. Every list entry spans two consecutive address locations the 1st contains a letter of the alphabet, and 2nd contains a pointer to the next list entry.

  Preparing a java program

Prepare a program that asks the user how many automobiles are to be explained, and for each automobile it inputs the user's selection of make and color.

  Write algorithm to identify substrings which form numbers

Write the algorithm, by using pseudo code, to do the following task. Given string of numbers, identify all the substrings which form numbers that are divisible by 3.

  Designing and populating a course table

Use data to design and populate a course table. Designate the CourseID field as a Primary Key and permit your database to automatically produce a value for this field.

  Implement a queue as a circular array

Implement a queue as a circular array as follows: Use two index variables head and tail that contain the index of the next element to be removed and the next element to be added.

  Creating an idef1x diagram

Construct an IDEF1X diagram that demonstrate only entities and relationships. Name each relationship and specify its cardinalities.

  Question about data network

The Minnesota Computer Consulting Group is a fifty person consulting services practice focusing on telecommunications and systems administration that includes Minnesota offices in Minneapolis, St. Paul, and Rochester.

  Design a simple algorithm by giving pseudocode

Design a simple algorithm by giving pseudocode, for constructing a binary search tree T on n elements in O(nlogn) time with the property that any Find operation on T takes O(logn) time.

  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.

  Learning for numeric prediction

Write down the output (class) values and number of instances that appear in each of the leaf nodes A, B and C of the tree - Learning for Numeric Prediction

  Calculation of a binary tree

Computations of a Binary Tree Write a function in C programming language that can find and return the height of a Binary Tree.

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