Modify the postfixeval class in the new header file to do


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

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: Modify the postfixeval class in the new header file to do
Reference No:- TGS02902650

Expected delivery within 24 Hours