Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can I please get some help? This is the code im using but when I run it in a C++ compiler, it messes up at

Can I please get some help? This is the code im using but when I run it in a C++ compiler, it messes up at the end. I will provide my code, the background info of the assignment, and a screenshot of me running the code.

CODE:

#include #include #include #include // ***** added /* void getEquation(stack & equation); void getConversion(stack equation, int choice); void getEvaluation(int choice, stack & equation, int choice2); void getValueConvert(int num1, int num2, int choice2, string operation); */ void getEquation( std::stack<:string> & equation); // **** void getConversion(std::stack<:string> equation, int choice); // **** void getEvaluation(int choice, std::stack<:string> & equation, int choice2); // **** void getValueConvert(int num1, int num2, int choice2, std::string operation); // ****

//put the voids for each method here using namespace std; int main() {

stack equation; getEquation(equation);

return 0; }

void getEquation(stack & equation) { string num1, num2, operation; int choice; cout > choice;

switch(choice) { case 1: { cout > num1; cout > operation; cout > num2;

equation.push(num1); equation.push(operation); equation.push(num2); } break;

case 2: { cout > operation; cout > num1; cout > num2;

equation.push(operation); equation.push(num1); equation.push(num2); } break;

case 3: { cout > num1; cout > num2; cout > operation;

equation.push(num1); equation.push(num2); equation.push(operation);

} break; default: getEquation(equation);

} getConversion(equation, choice); } void getConversion(stack equation, int choice) { int choice2; cout > choice2;

while(choice == choice2) { cout > choice2; } getEvaluation(choice, equation, choice2); } void getEvaluation(int choice, stack & equation, int choice2) { int num1 = 0, num2 = 0 ; // **** string operation;

switch(choice) { case 1: { num2 = stoi(equation/*.pop()*/ .top() ); // **** operation = equation/*.pop()*/ .top(); // **** num1 = stoi(equation/*.pop()*/ .top() ); // ****

}

break; case 2: { num2 = stoi(equation/*.pop()*/ .top() ); // **** num1 = stoi(equation/*.pop()*/ .top() ); // **** operation = equation/*.pop()*/ .top(); // **** } break; case 3: { operation = equation/*.pop()*/ .top(); // **** num2 = stoi(equation/*.pop()*/ .top() ); // **** num1 = stoi(equation/*.pop()*/ .top() ); // **** } break; } double answer; if(operation == "+" ) { answer = num1 + num2; } else if(operation == "-") { answer = num1 - num2; } else if(operation == "*") { answer = num1 * num2; } else if(operation == "/") { answer = num1 / num2; } cout

getValueConvert(num1, num2, choice2, operation);

} void getValueConvert(int num1, int num2, int choice2, string operation) { switch(choice2) { case 1: cout

BACKGROUND INFO ON ASSIGNMENT:

Write a C++ program that will do the following:

  1. Ask the user to enter the option to pick between infix, prefix, or postfix.
  2. Allow the user to enter a mathematical expression per the option above.
  3. Allow the user to enter the option to pick between infix, prefix, or postfix.
  4. Ensure that the user does not pick the same exact option again.
  5. Validate that the expression entered is correct per the option picked in step 1.
  6. Evaluate the expression entered per the option selected in step 1.
  7. Display the value produced in the above step.
  8. Convert the expression to be represented per the option picked in step 3.
  9. Display the new expression after being converted in the above step.
  10. Evaluate the expression after being converted.
  11. Display the value produced in the above step.

image text in transcribed

C Not secure cpp.sh cout

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions