Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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 #include // Provides set to set the width of an output 7 #include // Provides cout, cin 8 #include // Provides EXIT_SUCCESS 9 #include "stats.h" 10 using namespace CISP430_A1; 11 using namespace std; 12 13 // PROTOTYPES of functions used in this test program: 14 void print_menu(); 15 // Postcondition: A menu of choices for this program has been written to cout. 16 // Library facilties used: iostream.h 17 18 char get_user_command(); 19 // Postcondition: The user has been prompted to enter a one character command. 20 // A line of input (with at least one character) has been read, and the first 21 // character of the input line is returned. 22 23 double get_number(); 24 // Postcondition: The user has been prompted to enter a real number. The 25 // number has been read, echoed to the screen, and returned by the function. 26 27 void print_values(const statistician& s); 28 // Postcondition: The length, sum, minimum, mean, and maximum of s have been 29 // written to cout, using a field width of 10 for each of these values. 30 // (If length is zero, then minimum, mean, and maximum are not written.) 31 32 int main() 33 { 34 statistician si, s2, s3; // Three statisticians for us to play with 35 char choice; // A command character entered by the user 36 double x; // Value for multiplication x*s1 37 57 58 59 cout > X; ; 86 s3 = x * $1; 87 cout > command; 122 123 return command; 124 } 125 126 double get_number() 127 // Library facilties used: iostream.h 128 { 129 double result; 130 131 cout > result; 133 cout 7 #include 8 #include 9 #include // Provides memcpy function 10 #include "stats.h" 11 using namespace CISP430_A1; 12 using namespace std; 13 14 const int SCOREO=0, SCORE 1=100, SCORE2=25; 15 16 bool close (double a, double b) 17 { 18 const double EPSILON = le-5; 19 return (fabs (a-b) 0) cerr 0) cerr 0) cerr 0) cerr 0) cerr

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

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

Students also viewed these Databases questions