Question: 1 // Provided by: (your name here) Go Back Email Address: (your email address here) 3 // FILE: stats.h 4 // CLASS PROVIDED: statistician 5


1 // Provided by: (your name here) Go Back Email Address: (your email address here) 3 // FILE: stats.h 4 // CLASS PROVIDED: statistician 5 (a class to keep track of statistics on a sequence of real numbers) 6 This class is part of the namespace main_savitch_2c. 7 // 8 // CONSTRUCTOR for the statistician class: statistician(); 10 // Postcondition: The object has been initialized, and is ready to accept 11 // a sequence of numbers. Various statistics will be calculated about the 12 // sequence. 13 // 14 // PUBLIC MODIFICATION member functions for the statistician class: 15 // void next(double r) 16 // The number r has been given to the statistician as the next number in 17 its sequence of numbers. 18 // void reset(); 19 Postcondition: The statistician has been cleared, as if no numbers had 20 // yet been given to it. 21 // 22 // PUBLIC CONSTANT member functions for the statistician class: 23 // int length() const 24 // Postcondition: The return value is the length of the sequence that has 25 // been given to the statistician (i.e., the number of times that the 26 // next(r) function has been activated). 27 // double sum( ) const 28 // Postcondition: The return value is the sum of all the numbers in the 29 // statistician's sequence. 30 double mean() const 31 Precondition: length() > 32 Postcondition: The return value is the arithmetic mean (i.e., the 33 // average of all the numbers in the statistician's sequence). 34 // double minimum( ) const 35 // Precondition: length() > 0 36 // Postcondition: The return value is the tinyest number in the 37 // statistician's sequence. 38 // double maximum( ) const 39 // Precondition: length() > 0 40 // Postcondition: The return value is the largest number in the 41 // statistician's sequence. 42 // 43 // NON-MEMBER functions for the statistician class: 44 statistician operator +(const statistician& si, const statistician& s2) 45 // Postcondition: The statistician that is returned contains all the 46 // numbers of the sequences of s1 and s2. 47 statistician operator *(double scale, const statistician& s) 48 // Postcondition: The statistician that is returned contains the same 49 // numbers that s does, but each number has been multiplied by the 50 // scale number. 51 bool operator ==(const statistician& si, const statistician& s2) 52 // Postcondition: The return value is true if s1 and s2 have the zero 53 // length. Also, if the length is greater than zero, then si and s2 must 54 // have the same length, the same mean, the same minimum, 55 // the same maximum, and the same sum. 56 // 57 // VALUE SEMANTICS for the statistician class: 58 // Assignments and the copy constructor may be used with statistician objects. 59 69 70 75 76 60 #ifndef STATS_H // Prevent duplicate definition 61 #define STATS_H 62 #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
