Question: Problem 2 (6 points) Write a program called Structcalc.cpp. The program should have functions for add, subtract, multiply, and divide. Each of these four functions


Problem 2 (6 points) Write a program called Structcalc.cpp. The program should have functions for add, subtract, multiply, and divide. Each of these four functions will accept a structure called Operands as an input argument. You must demonstrate the program works by writing amain() that tests each function as shown in the execution sample given below. The program MUST contain the following features Declaration of a structure called Operands that contains two member variables of type double Four functions that each have an input parameter of type Operands Each function will return a double that corresponds to the result ofadding, subtracting, multiplying, or dividing the two member variables of the input parameter. The first member variable corresponds to the first operand and the second member variable corresponds to the second operand. * * . You must check that the second operator is not zero in main () to prevent a divide-by-zero error o A sample run of the program using multiple inputs is shown below: Please enter two operands 5 0 Here are the results of add / subtract /multiply / divide: Add Subtract: Multiple: Divide:5.00/ Would you like to enter more pe rands (Y/N)? y Please enter two operands 10 20 0.00- 0.00- 0.00- 0.00 Undefined 5.00 + 5.00 5.00 * 5.00 5.00 0.00 Here are the results of add / subtract / multiply / divide: Add Subtract10.00 Multiple10.00* Divide : 10.00 / 20.00 Would you like to enter more pe rands (Y/N)? y Please enter two operands 20-30 : 10.00 + 20.00 - 20.00 - 30.00 10.00 20.00 200.00 0.50 Here are the results of add / subtract /multiply / divide: Add Subtract20.00 Multiple: 20.00 * -30.00= -600.00 Divide : 20.00/ -30.00 Would you like to enter more operands (Y/N)? n : 20.00-30.00-10.00 50.00 3000 = -0.67 Pressany kev tocontinue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
