Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and create a (C++) class named Stats that has an array of 12 doubles as one of its member variables. The values in the

Design and create a (C++) 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 displayValues function that displays all of the values in the array (cout is ok for this one)

A calcTotal function that calculates and returns the total of the 12 values in the array

A calcAverage function that calculates and returns the average of the 12 values in the array

A calcLargest function that calculates and returns the largest value in the array

A calcSmallest function that calculates and 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 employee class should be in a separate .cpp file. Name this program raainfall.cpp.

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

What are the objectives of performance appraisal ?

Answered: 1 week ago

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago

Question

1. Which position would you take?

Answered: 1 week ago