The infix to postfix conversion

Assignment Help Data Structure & Algorithms
Reference no: EM132109195

For programming we are going to work with infix to postfix conversion. The starting point for the assignment is the infix to postfix conversion program provided by the textbook (program 7-3).

A code blocks project with all the associated header files for this program is uploaded on canvas for your starting point. As provided the program issues two warnings and the error and exception handling does not work.

The warnings are minor and do not cause a problem. Do not worry about the exception handling at this point. We are going to cover exception later in the course.

If you input an invalid expression the program will lock up. You can just restart if that happens. At first run the program with the examples to see how the program functions.

The main task of the assignment is to write your own stack class and use your stack to replace the stack from the standard library used by program 7-3.

Program 7-3 uses the standard library stack in two places d_rpn.h and d_inftop.h. Your stack must use a dynamically allocated array that grows as neededto store stack the items. We covered how to do this in class with the miniVector class.

The miniVector class is included with the material for the assignment. Your stack will also need to have functions top, push, pop, size and empty. These are the functions required by program 7-3.

Your stack should also include a destructor to release the dynamically allocated memory at the programs completion. Hint: if you use a template class you only have to implement a single stack class for this assignment. Test your stack by pushing 0 through 9 on to the stack. Then use top to read the top value and pop to remove all elements from the stack. If your stack is working correctly you should get 9 through 0 out.

After removing all ten items from the stack the empty function should return true. Include this output in your report to show that your stack is working.

Next, use your to stack to replace stack used in d_rpn.h and d_inftop.h. You can simply add another header file with your stack class to the provided code blocks project. Be sure to add #includes to your stack in the correct places so that the compiler can find your stack class.

If everything is working correctly program 7-3 will operate just as it did before. Run the program with sample test data and include this output in your report.

As implemented program 7-3 only does integer math. So if you input 1/2 the value returned is 0. Modify the postfixEval class found in d_rpn.h so that it returns a double value.

Hint: the remainder operator is not defined for double math and is no longer needed. Remove the remainder operator from the list of operators. One way to implement the double math is to add another header file to the project for double math.

Copy postfixEval into that new header file. It is okay two have two postfixEval versions in different header files. The version that the compiler will use is determined by the include directive in the main program.

Modify the postfixEval class in the new header file to do double math. Rerun the sample test data and include the output in your report.

Sample Test Data:

22

8-3*2

7+(4-6)*(8+6)/3

4+1+(2-1)

3/8+4*5

9*2+((4-3)*2)/2

Reference no: EM132109195

Questions Cloud

Display how many of each denomination would be needed : Write a C++ program that prompts the user for a cash value and an amount of purchases made against that amount.
Compute the acceleration of gravity for a given distance : Compute the acceleration of gravity for a given distance from the earth's center, dist_center, assigning the result to accel_gravity.
Develop using android studio a rent a car app : HC2051 - design and develop using Android studio a Rent a Car App, that provides a listing of six Australian known car rental companies. By selecting a car
Write a function that outputs everything in the order : Write a function that outputs everything in the order along with the total price. Write a suitable test program that adds multiple pizzas to an order(s).
The infix to postfix conversion : Modify the postfixEval class in the new header file to do double math. Rerun the sample test data and include the output in your report.
Design a program with loop that let the user enter a series : Design a program with loop that let the user enter a series of numbers. Compare each number to the current maximum and minimum.
Write a java program that will ask the user : Write a Java program that will ask the user to enter three integer numbers and find the greatest or the smallest of these numbers.
Create the logic for a program that performs functions : Create the logic for the methods sum() and difference(); they compute the sum of and difference between the values of two arguments, respectively.
Differences in the way the process is performed : ACC203 – Accounting Information Systems - What are the major differences in the way the process is performed - Explain how this case demonstrates

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Construct a process-flow diagram

Construct a process-flow diagram that illustrates the process of determining the incident containment strategy that would be used in this scenario, and identify which containment strategy would be appropriate in this case, through the use of graphica..

  List four skus that were purchased most frequently together

List the three SKUs that were purchased most frequently together. List the four SKUs that were purchased most frequently together.

  Discuss when you think a hash table should be used

Discuss when you think a hash table should be used and when you think it should it be avoided. Reply to others with support for or arguments against the use of hash tables in given circumstances.

  Data speed effect on fundamental business decisions

Can the speed in which data is transmitted have an adverse effect on fundamental business decisions? Yes, speed that is traveling at big rates of speed can have an affect on fundamental business decisions.

  Written to model a railroad switching yard

CSIS- 210 - Data Structures. A program is to be written to model a railroad switching yard. One part of the switching network consists of a main track and a siding that contains four exits onto which cars may be shunted and removed later

  Creating java programming scripts

Discuss how does a programmer typically get access to a Graphics object when coding an applet?

  1 early printings of clrs3 say on pages 546-547 we treat

1. early printings of clrs3 say on pages 546-547 we treat min and max differently the element stored in min does not

  Find min returns the minimum key in the search tree

Find min returns the minimum key in the search tree, find min obj returns the object belonging to the minimum key,

  How to work on datasturetur assignment how to work on

how to work on datasturetur assignment how to work on datasturetur assignment how to work on datasturetur

  What is a race condition in software

What is a race condition in software? Why are race conditions difficult to debug?

  Write a program that creates a two-dimensional array in heap

Write a program that creates a two-dimensional array in the heap and then analyzes it to determine the minimum, maximum, and average of each column.

  Use ms project to complete a gantt chart

Gantt Chart: Use MS Project to complete a Gantt Chart that shows your work to date so far on this project based on the first two team submissions. This chart should show reasonable tasks, durations, and dependencies, look professional, and be prin..

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