Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me with this question. Question has precode files, I am attaching screenshots of them. Sorry that i am uploading screenshots side by side,
Please help me with this question. Question has precode files, I am attaching screenshots of them. Sorry that i am uploading screenshots side by side, the question was too long. question starts from the left side then right....
I know the difficulty of reading the question, the problem is that if i post the question only the precode files will left behind and vice versa. please help me with this
You will create, implement and test a small class called statistician, which is similar to some of the small classes in Chapter 2 of the text. The new class is called statistician, using a header file, stats,h (attached).(most of which is written for you) and an implementation file, stats.cpp (which you need to create and implement.). The statistician is a class that is designed to keep track of simple statistics about a sequence of real numbers. There are two member functions that you should understand at an informal level before you proceed any further. The prototypes for these two functions are shown here as part of the statistician class declaration: class statistician A constant member function called length, which returns the count of how many numbers have been given to the statistician Two constant member functions called minimum and maximum, which return the smallest and largest numbers that have been given to the statistician. (By the way, these two functions and the mean function all have a precondition that requires length > 0. You cannot use these three member functions unless the statistician has been given at least one number!) A constant member function called sum, which returns the sum of all the numbers that have been given to the statistician. This function does NOT have a precondition. It may be called even if the statistician has NO numbers (in which case it should return 0). An overloaded operator == which tests to see whether two statisticians are "equal". The prototype is: bool operator = (const statistician s, const statistician& t); public: void next (double r); double mean() const; ); The member function "next" is used to give a sequence of numbers to the statistician one at a time. The member function "mean" is a constant member function that returns the arithmetic mean (i.e., the average) of all the numbers that have been given to the statistician. Example: Suppose that you want a statistician to compute the mean of the sequence 1.1, 2.8,-0.9. Then you could write these statements: // Declares a statistician object called s statistician si // Give the three numbers 1.1, 2.8 and -0.9 to the statistician S.next(1.1); Sunext (2.8); S.next(-0.9); // Call the mean function, and print the result followed by a carriage return cout 61 62 namespace CISP430 A1 63 { { 64 class statistician 65 { public: 67 // CONSTRUCTOR 68 statistician(); 69 // MODIFICATION MEMBER FUNCTIONS 70 void next(double r); 71 void reset(); 72 // CONSTANT MEMBER FUNCTIONS 73 int length() const { return count; } 74 double sum( ) const { return total; } 75 double mean() const; 76 double minimum( ) const; 77 double maximum() const; 78 // FRIEND FUNCTIONS 79 friend statistician operator + 80 (const statistician& si, const statistician& s2); 81 friend statistician operator * 82 (double scale, const statistician& s); 83 private: int count; // How many numbers in the sequence 85 double total; // The sum of all the numbers in the sequence 86 double tiniest; // The smallest number in the sequence 87 double largest; // The largest number in the sequence 88 }; 89 90 // NON-MEMBER functions for the statistician class 91 bool operator ==(const statistician& si, const statistician& s2); 92 ) 93 98 | Phi 95 84 The following choices are available: R Activate one of the reset() functions 1 Add a new number to the 1st statistician si 2 Add a new number to the 2nd statistician 2 3 Add a new nunber to the 3rd statistician 33 T Print a table of values from the statisticians E Test whether s1 - 32 Set the third statistician s3 equal to si s2 Set the third statistician 93 equal to x1 Q Quit this test progran Enter choice: : Please document the stats.cpp file properly and zip that into a proper named zip file for the assignment (refer to the assignment section of the class syllabus) and submit it to the cout // Provides toupper 6 #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started