Question
Use C++ write a Design and implement a class of infix calculators ,simply write a function named evaluateInfix() that evaluates infix expressions. It should have
Use C++ write a "Design and implement a class of infix calculators" ,simply write a function named "evaluateInfix()" that evaluates infix expressions. It should have one string parameter and should return an int result. It should call a separate function named "infixToPostfix()" to convert the infix expression into a postfix expression, and then it should do the work of evaluating the resulting postfix expression. Then write a main() function to thoroughly test the function.
The program is complete, but I am having an issue debugging it! Can someone help?
#include
#include
#include
#include
using namespace std;
int precedence(char ch) { switch (ch) { case '+': case '-': return 1; case '*': case '/': return 2; default: return 0; } }
string evaluateInfix(const string infix) { stack
return postfix; } int main() { string infix, postfix; while (true) { getline(cin, infix); infix = infix.substr(0, infix.length() - 1); if (infix.length() == 0) break; postfix = evaluateInfix(infix); cout << postfix << endl << endl; } return 0; }
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