Faria R.

asked • 08/12/21

Our whole class cannot slovingit,please help sir,Use Application of Stack and Queue .

Question: Write a code in C++ [using object oriented approach] that will take a mathematical expression as input and output whether the parentheses are balanced or not in the expression.                          [10 points]


Sample Input: (5 + (9-(3+2))+ 4)

Sample Output: Balanced 


Sample Input: (5 + (9-(3+2)+ 4)

Sample Output: Not Balanced


Note:[using object oriented approach]

[NOTE]


Sir,last time your this code was not compiled and show several errors.


Mail:Fariamahbub630@gmail dot com ,send the code when it is complied.Thank u.


Faria R.

using namespace std; #include #include #include #include /**************************************** * if LEFT PARENTHESIS '(' is encountered: pushes onto the stack... *if RIGHT PARENTHESIS ')' is encountered: if the stack is empty, then NOT BALANCED !!! (too many RIGHT PARENTHESIS) otherwise pops off th stack; * AFTER the loop if the stack is empty, then the parenthesis are BALANCED! Otherwise they are not!! (too many LEFT Parenthesis) **************************************************************/ DoStack(char * mathExpression) { cout << "** Using the STACK to Verify that the parenthesis are BALANCED *** "<< endl; cout << "The math expression is:>"< _stack; int x=1; bool boolBalancedFlag = true; for (int iLoop=0; iLoop"< Q; int x=1; for (int iLoop=0; iLoop
Report

08/12/21

Faria R.

your last code ☝️
Report

08/12/21

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.