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 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 array of pointers (not vector) to Expression objects to manage the list of Expression objects. Please predefine the size of the array to start at 10. Every time, the array is full, please allocate a new array with 10 more, copy the original array to the new one and free the original one. - 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. The expected output is attached.
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
add, listall, listbyoperator, listsummary, exit
- "add" command will read 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 array of pointers (not
- 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.
The expected output is attached.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images