Answered step by step
Verified Expert Solution
Question
1 Approved Answer
*********EMU8086 1. A problem in elementary algebra is to decide if an expression containing several kinds of brackets, such as {}, ], is correctly bracketed.
*********EMU8086
1. A problem in elementary algebra is to decide if an expression containing several kinds of brackets, such as {}, ], is correctly bracketed. This is the case if a) there are the same number of left and right brackets of each kind, and b) when a right bracket appears, the most recent preceding left bracket should be of the same type. For example: (20 points) [a+b - {c + d} xe]: correctly bracketed [a+b - {c+d] x e]: not correct Write a program that- a) Shows a message, Enter an algebraic expression: " and lets the user type in an algebraic expression, ending with a carriage return, that contains each kind of brackets as stated above. b) As the expression is being typed in, the program evaluates each character. If the expression is typed correctly, the program displays Expression is correct" and the program is terminated. If at any point the expression is incorrectly bracketed (mismatch between left and right bracket), the program terminates and shows a message "Incorrect expression". Example 2 Example 1 Enter an algebraic expression: (a + b - {c + a) Incorrect expression. Enter an algebraic expression: (a + {b-c}xf]-h Expression is correctStep 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