Question: Make sure and use three separate files for your object oriented programs (two .cpp files and one .h file) plus UML diagrams. Do not use
Make sure and use three separate files for your object oriented programs (two .cpp files and one .h file) plus UML diagrams. Do not use inline functions.
NO GLOBAL VARIABLES (global constants are fine)
Design (using a UML) and create a class named Stats that has an array of 12 doubles as one of its member variables. The values in the array should be set by making 12 calls to a public member function named setValue that accepts two arguments, an integer indicating which value is being provided (the first number, the second number.etc) and a double holding the actual data value.
In addition to the setValue member function, the class should have the following additional member functions:
A default constructor that sets all of the values in the array to zero
A printValues function that displays all of the values in the array
A getTotal function that returns the total of the 12 values in the array
A getAvg function that returns the average of the 12 values in the array
A getLargest function that returns the largest value in the array
A getSmallest function that returns the smallest values in the array
Remember that the class specification/declaration (.h file) will contain the member variables and member function prototypes. Name the class declaration file Stats.h. The class implementation file (.cpp) will contain the function definitions (dont forget to include the Stats.h file). Name the class implementation file Stats.cpp.
Next create a program that uses the Stats class to hold rainfall data and report annual rainfall statistics. The program should first create a Stats object named rainfall and call its setValue member function to set each of the 12 monthly rainfall totals to a user entered amount. It should then produce an annual rainfall report that shows the total, average, lowest and highest rainfall amounts for the year. Note that the printing of the rainfall report should be done in the client program file not in the Stats class.
Input Validation: If any amount less than 0 is passed into the setValue function, a default value of 0 should be used in his place.
The program utilizing the stats class should be in a separate .cpp file. Name this program rainfall.cpp.
Note: Do not use the class to store the average or total. It makes the program more complex and you can get stale data if you dont update it regularly. So just use local variables and not data members for average and total.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
