Question: Design and implement a class called statistician. After a statistician is initialized, it can be given a sequence of double numbers by invoking a member

Design and implement a class called statistician. After a statistician is initialized, it can be given a sequence of double numbers by invoking a member function next. For example, we can declare a statistician called s, and then give it the sequence of numbers 1.1, -2.4, 0.8 as shown here: statistician s; s.next(1.1); s.next(-2.4); s.next(0.8); After a sequence has been given to a statistician, there are various member functions to obtain information about the sequence. Include member functions that will provide the length of the sequence, the sum of all the numbers in the sequence, the arithmetic mean of the numbers, the smallest number in the sequence, and the largest number in the sequence. Notice that the length and sum functions can be called at any time, even if there are no numbers in the sequence. In this case of an empty sequence, both length and sum will be zero. But the other member functions all have a precondition requiring that the sequence is non-empty. Please implement stats.cpp given the following stats.h header file

#ifndef STATS_H #define STATS_H class statistician { public: // CONSTRUCTOR statistician( ); // MEMBER FUNCTIONS void next(double r); // CONSTANT MEMBER FUNCTIONS int length( ) const { return count; } double sum( ) const { return total; } double mean( ) const; double minimum( ) const; double maximum( ) const; private: int count; // How many numbers in the sequence double total; // The sum of all the numbers in the sequence double tiniest; // The smallest number in the sequence double largest; // The largest number in the sequence }; } #endif

Please help. I haven't done a programming assignment in many quarters so I'm very rusty and having a hard time understanding where to start. Thanks!

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!