Question
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
//put the voids for each method here using namespace std; int main() {
stack
return 0; }
void getEquation(stack
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
while(choice == choice2) { cout > choice2; } getEvaluation(choice, equation, choice2); } void getEvaluation(int choice, stack
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:
- Ask the user to enter the option to pick between infix, prefix, or postfix.
- Allow the user to enter a mathematical expression per the option above.
- Allow the user to enter the option to pick between infix, prefix, or postfix.
- Ensure that the user does not pick the same exact option again.
- Validate that the expression entered is correct per the option picked in step 1.
- Evaluate the expression entered per the option selected in step 1.
- Display the value produced in the above step.
- Convert the expression to be represented per the option picked in step 3.
- Display the new expression after being converted in the above step.
- Evaluate the expression after being converted.
- Display the value produced in the above step.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started