Question: please help me ... :( IMPORTANT INSTRUCTIONS (follow these to avoid losing points NO LATES) Submit your source code files (all .h and .cpp files),

please help me ... :(

IMPORTANT INSTRUCTIONS (follow these to avoid losing points NO LATES)

Submit your source code files (all .h and .cpp files), make sure your name is on each file you submit.

Make sure and use three separate files for your object oriented programs (this means for each program you need to submit three files on Moodle (two .cpp files and 1 .h file) plus UML diagrams. Do not use inline functions. IF YOU VIOLATE THESE RULES points off.

NO GLOBAL VARIABLES no exceptions. Programs with global variables will not be accepted (global constants are fine)

Program 1: Extend Stats class and Rainfall Statistics Based on Chapter 9 lecture and struct (25 pts)

Take program #2 of lab 7 and extend the class named Stats. Add a struct called All that will have an average, max, and min double values.

It should have added to the Stats class:

A readValuesFromFile function that takes a filename as a parameter, opens the file for input, zeros the array, and reads all the values the file has into the array

A getAll function that makes a temporary variable, temp, of type All, sets its average to getAvg, max to getLargest, and min to getSmallest and returns temp (not as a reference parameter but a return type)

Have another function that is not part of the class called:

A writeStatsToFile function that takes a filename as a parameter and an All parameter, opens the file for output, and sends statistics report to the file using the All parameter

Extend the class in Stats.h and put the All struct in Stats.h also. The class implementation file (.cpp) will contain the function definitions and the additions (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 read rainfall data from a file ("rainfall.dat" is a good name) and report annual rainfall statistics.

An example of "rainfall.dat" file is:

12.4

15.9

19.2

23

5.3

1.2

0.2

3.7

7.3

9

11.1

14.6

The program should first create a Stats object named rainfall and call its readValuesFromFile member function to set each of the 12 monthly rainfall totals from the file. It should then use the getAll function to set variable values of All data type, then print the statistics using that variable. Then call writeStatsToFile, using a different filename (suggested "rainstats.dat") and the All variable of values, to print the stats report to the disk. Note that the printing of the rainfall report should be done in the client program file not in the Stats class though sending the report to disk is done with the Stats class.

The program utilizing the extended stats class should be in a separate .cpp file. Name this program rainfallextend.cpp.

Note: Those using XCode on a Mac, you need to make a project then change the working directory to $PROJECT_DIR/. and you do that by selecting Product/Scheme/Edit Scheme. Then go to the Working Directory part, select Use custom working directory box, then put in the $PROJECT_DIR/. in the box (without the quotes, of course). That will allow selecting data files that are in the same directory as your source code.

Windows users just need to place the data file under the same directory as the program code.

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!