Define a C++ class named "Expression" that manages an 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 10 + 20 = 30 It must NOT store the expression result as a data member because it can be calculated when needed. Write a command-driven program named "ListExpressions" that will accept the following commands:
Objectives:
Solve problem, design solution and implement using C++ Class and Objects
Learn how to manipulate C++ arrays of objects using
Use C++ stream to read in data and format output
Description:
Define a C++ class named "Expression" that manages an 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
10 + 20 = 30
It must NOT store the expression result as a data member because it can be calculated when needed.
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 expressions for each operator, the largest and smallest expression values
- "exit" command will exit the program
Requirements:
1. The program must produce the same expected output as provided.
2. It must be using the vector object to manage the list of Expression objects. Because the vector class can support any size, there is no need to limit the number of expressions that can be entered.
4. There should be no global variables. Please use only local variables and parameters instead
5. Scanf and printf are not allowed (Please use C++ cin and cout and C++ formatting)
6. Should handle error condition when the user enters invalid operators, invalid operand and invalid command.
7. It should display "There is no expression." when no expression is in the list.
8. When the user enters "listbyoperator" command and there is no matched expression, it should display "No expression is found with the operator: <search-operator>" message such as "No expression is found with the operator: $"
9. Each expression must be stored in its own Expression object
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images