Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a class Math_1 which has two member functions: add() and subtract(). Both require two integer arguments. The functions calculate the sum and difference of

image text in transcribed
Define a class Math_1 which has two member functions: add() and subtract(). Both require two integer arguments. The functions calculate the sum and difference of the two integers, respectively. Then declare a class Math_2 to inherit Math_1, and Math_2 also has two member functions multiply() and divide(). Similarly, both require two integer arguments, and the functions calculate the product and division results of the two integers. Declare a Math_2 type variable in main(), and two integer variables. Assign integers using cin, and prompt the user to make one of the four choices: 1, 2, 3, or 4; which represents the four member functions defined above (add, subtract, multiply, and divide). Then call the related member function to calculate and print the result. Using template to define a class which has two member functions: sorting() and max_min_mean(). The 1^st function take an array parameter in template data type and sorts the data, the 2^nd function also take an array parameter in template data type and find the max, min, and mean values of the array and print them. In main(), declare one int array and one double array and assign the array with integer and real numbers, then declare two object variables using the class defined above and initialize one's template type to int and the other to double. After that, complete: (1) use the first object variable's member function sort() to sort the int array and print the sorted result, and then use the first object variable's member function max_min_mean() to output the three key values of the int array: (2) use the 2nd object variable's member function sort() and max_min_mean() to do the same as in (1) to the double array: Please find a classmate to form a study group and use pair programming method to help each enhance programming skills: for each program, one will write the program (driver) and the other will verify if the writing is correct or not (navigator). Note that you need to take turns to write and verify (e.g. in program 1, person A writes the code and person B checks it; in program 2, person B writes the code and person A checks it). Please state clearly in the comments who typed the code and who checked and tested In each program. The following specifications will be expected for each of your projects for this class: An empty project file must be created first, and then you will create new source file and header files. Add comments at the beginning of the program, and add description for each function, loop, etc. Turn in both the hardcopy and softcopy of your source code, including all .cpp and .h file. Your name, your ID number and lab number should be written on the upper right-hand corner of the top sheet of the hardcopy. Note that you are required to submit your softcopy through homework 5 link in eCouse

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions