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 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.
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
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 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: <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.
Step by step
Solved in 4 steps with 2 images