Question: Use C++ TO create the program Here is the starter code /* * Define class Averager that maintains the average for * any number of

Use C++ TO create the program

Here is the starter code

/* * Define class Averager that maintains the average for * any number of quiz or test scores. * * File name: Average.h (available on this book's website) * pages 168 - 167 */ class Averager { public: // Construct an Averager with no scores added. Averager(); //-- modifiers void addScore(double score); // post: Add a score so the count and average are correct. //--accessors double getAverage() const; // post: Return the average of all scores entered. int getScoresAdded() const; // post: Return how many scores were added private: int n; // number of scores added so far, initially 0 double sum; // total of all scores added, initially 0.0 }; 

---------2nd half of the program

//Week0X Example.cpp //this program ... #include "Averager.h" #include  // for setw and right #include  // for cout, cin, system("pause") using namespace std; // so I don't have to say iostream::cout int main() { Averager averager; cout.setf(ios::fixed, ios::floatfield); // stops scientific notation cout.setf(ios::showpoint); // forces decimal points cout.precision(2); // sets the number of decimal to 2 cout  

Add Averager.h and 6C_averagerTestDriver.cpp to your project working directory.

Right-click on source files (in Visual Studio Solution Explorer) and add / existing 6C_averagerTestDriver.cpp

Right-click on source files Add / New Item to create the new Avenger.cpp file.

Add to top of the file (Averager.cpp). //student name #include using namespace std #include "Averager.h"

To view Averager.h , right-click Averager.h and select Open Document "Averager.h" (see image below )

Look in Averager.h file and you will find 4 functions (one constructor, one modifier and 2 accessor functions which are const).

Copy just the 4 function declarations to your new file (Averager.cpp).

Add the name of the class and the scope resolution operator before each function name and replace the semi-colon with { }

e.g. Averager(); = Averager::Averager() {} e.g. void Averager::addScore(double score) {}

Write the function code in the empty body for each class function.

When referring to a class variable, include the class name and resolution operator e.g. return Averager::sum / Averager::n ;

Important Note: Make sure you initialize your class variables (sum & n) to 0 and 0.0 in your constructor.

Submit the both 6C_averagerTestDriver.cpp (with output) and Avenger.cpp.

Activity 6.2 input/output:

Student Name, CIS127, Assignment 6.2 Count: 0 Average: 90.00 Count: 1 Average: 75.50 Count: 6 Press any key to continue . . .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!