Question: Create a header file for a class called Statistician Create a default constructor Statistician ( ) Create the next function void next ( double num
Create a header file for a class called Statistician
Create a default constructor Statistician
Create the next function
void nextdouble num
Include the operator as a binary operator so that it combines two Statistician objects.
Statistician operator const Statistician& s const Statistician& s;
Create getters for the variables:
average
total
numitems
maximum
minimum
Create the following double private variables:
average: represents the average of all of the numbers passed in through the next function
total: represents the total of all the numbers passed in through the next function
maximum: represents the largest of all of the numbers passed in through the next function
minimum: represents the smallest of all of the numbers passed in through the next function
Create an int private variable called numitems represents the total number of nums passed in through the next function. This is a counter.
Create the implementation file cpp file for the Statistician
The default constructor Statistician should assign zeros to total, average and numitems.
Code for the plus operator should:
add the totals together, add the numitems, recompute the average, compare the two maximums and assign the larger of the two to the resulting Statistician and similar process for minimum.
Code for the next function
Should add to the numitems
initialize maximum and minimum to the num passed in if numitems is equal to Otherwise, if num is bigger than maximum then maximum should be assigned num. If num is smaller than minimum, then minimum should be assigned the value of num.
Add num to the total
Update the average. Note average total numitems
Create a driver file cpp file with main that creates a default Statistician object, s
Call the next function on the object with the following values:
Sample usage:
obj.next;
obj.next;
Repeat for each of numbers in the list. This function feeds the numbers to your Statistician object. Each call to the function updates all of the variables in the object.
Use the getters to display all of the variables in the object there are variables in the following format:
:
Example: Information for numitems would print as
numitems :
How do I know it is correct?
Your output should look like:
Console showing for numitems, for total, for average, for maximum and for minimum.
Expected output values for each variable
Variable Value
numitems
total
average
maximum
minimum
Now, create a second Statistician object s and call the next function to insert and
snext;
snext;
snext;
Then add the first Statistician object to s and save the result in the third Statistician object.
Statistician s s s;
Display all of the values for Statistician s These are the values you should see:
Total:
numitems:
maximum:
average:
minimum:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
