Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design in C++ a program class Expression { public: //methods... private: string infix; string postfix; }; that contains a constructor: Expression(string input, int direction) {

Design in C++ a program

class Expression { public: 
 //methods... 
private: string infix; 

string postfix;

};

that contains a constructor:

 Expression(string input, int direction) { if (direction == 1) 
 infix = input; else if(direction == 2) postfix = input; 

} and three methods, inToPost, postToIn and evaluate

 string inToPost() { //... 
 } string postToIn() { 

//...

 } double evaluate() { 

//...

The first method transforms the local infix expression to postfix, stores it as the local postfix and returns it as a String. The second method is the inverse: it transforms the local postfix expression to infix, stores it locally, and returns it as a string. The method evaluate() returns the value of the expression.

Your main() should display a prompt to the user, give him/her the opportunity to enter a string in either notation (hence the two different directions in the constructor) to be transformed to the other, and evaluate the result. You will probably also need to declare different types of Stack classes, to be used each for a different purpose.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

Explain the functions of HRM.

Answered: 1 week ago

Question

=+Why does the demand curve slope downward?

Answered: 1 week ago