Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Objectives: Students will gain an experience to evaluate arithmetic expressions by stacks Students will gain an experience to handle errors using C++exceptions Students will gain
Objectives: Students will gain an experience to evaluate arithmetic expressions by stacks Students will gain an experience to handle errors using C++exceptions Students will gain an experience to analyze various aspects of the process used when designing a system and to employ established frameworks to evaluate the completed work e Problem Consider simple infix expressions that consist of single-digit operands; the operators+, , and/ and the parentheses. Assume that unary operators are illegal and that the expression contains no embedded spaces. Design and implement a class of infix calculators. Use the algorithms given in Chapter 6 to evaluate infix expressions as entered into the calculator. The calculator must first convert the infix expression to postfix form and then evaluates the resulting postfix expression. Requirement Use the link-based Stack with exceptions. Write a main function to test your calculators. Other Requirements a) You should not assume that the expression is well-formed. The user is asked to reenter an expression if the expression entered is not well-formed. b) You should not assume that the parentheses in the expression are balanced. The user is asked to reenter an expression if the expression entered is not balanced. Use the algorithm discussed in Chapter 6 to solve this problem. c Your program should allow the user to evaluate additional expressions until the user wants to end the prog Hint: When defining the class Calculator, use a private member function to check if an input expression is well formed use a private member function of to implement the algorithm that checks for balanced brackets. use a private member function of to implement the algorithm that converts an infix expression to a postfix expression e e e use a private member function of to implement the algorithm that evaluates a postfix expression. Users do not need to know these operations when using your calculator Objectives: Students will gain an experience to evaluate arithmetic expressions by stacks Students will gain an experience to handle errors using C++exceptions Students will gain an experience to analyze various aspects of the process used when designing a system and to employ established frameworks to evaluate the completed work e Problem Consider simple infix expressions that consist of single-digit operands; the operators+, , and/ and the parentheses. Assume that unary operators are illegal and that the expression contains no embedded spaces. Design and implement a class of infix calculators. Use the algorithms given in Chapter 6 to evaluate infix expressions as entered into the calculator. The calculator must first convert the infix expression to postfix form and then evaluates the resulting postfix expression. Requirement Use the link-based Stack with exceptions. Write a main function to test your calculators. Other Requirements a) You should not assume that the expression is well-formed. The user is asked to reenter an expression if the expression entered is not well-formed. b) You should not assume that the parentheses in the expression are balanced. The user is asked to reenter an expression if the expression entered is not balanced. Use the algorithm discussed in Chapter 6 to solve this problem. c Your program should allow the user to evaluate additional expressions until the user wants to end the prog Hint: When defining the class Calculator, use a private member function to check if an input expression is well formed use a private member function of to implement the algorithm that checks for balanced brackets. use a private member function of to implement the algorithm that converts an infix expression to a postfix expression e e e use a private member function of to implement the algorithm that evaluates a postfix expression. Users do not need to know these operations when using your calculator
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