C++ Define an "Expression" class that manages expression info: operand1 (integer), operand2 (integer), and the expression operator (char). It must provide at least the following method: - toString() to return a string containing all the expression info such as 50 + 50 = 100 Write a command-driven program named "ListExpressions" that will accept the following commands: add, listall, listbyoperator, listsummary, exit "add" command will read in the expression and save it away in the list "listall" command will display all the expressions "listbyoperator" command will read in the operator and display only expressions with that given operator "listsummary" command will display the total number of expressions, the number of expressions for each operator, the largest and smallest expression values "exit" command will exit the program Requirements: - It must be using the vector object to manage the list of Expression objects. - There should be no global variables. - No - scanf and printf, please use cin, cout and C++ formatting) - Should handle error conditions when the user enters invalid operators, invalid operands, and invalid commands. - It should display "There is no expression." when no expression is in the list. - When the user enters "listbyoperator" command and there is no matched expression, it should display a "No expression is found with the operator: " message such as "No expression is found with the operator: @" - Each expression must be stored in its own Expression object.
C++
Define an "Expression" class that manages expression info: operand1 (integer), operand2 (integer), and the expression operator (char). It must provide at least the following method:
- toString() to return a string containing all the expression info such as
50 + 50 = 100
Write a command-driven program named "ListExpressions" that will accept the following commands:
add, listall, listbyoperator, listsummary, exit
- "add" command will read in the expression and save it away in the list
- "listall" command will display all the expressions
- "listbyoperator" command will read in the operator and display only expressions with that given operator
- "listsummary" command will display the total number of expressions, the number of expressions for each operator, the largest and smallest expression values
- "exit" command will exit the program
Requirements:
- It must be using the vector object to manage the list of Expression objects.
- There should be no global variables.
- No - scanf and printf, please use cin, cout and C++ formatting)
- Should handle error conditions when the user enters invalid operators, invalid operands, and invalid commands.
- It should display "There is no expression." when no expression is in the list.
- When the user enters "listbyoperator" command and there is no matched expression, it should display a "No expression is found with the operator: <search-operator>" message such as "No expression is found with the operator: @"
- Each expression must be stored in its own Expression object.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images