Question: In this assignment, you will write a program that will read in a list of 1 2 doubles from a file. Each double represents the

In this assignment, you will write a program that will read in a list of 12 doubles from a file. Each double
represents the total rainfall in inches for the 12 months of the year in month order. The 12 doubles
should be written into an array.
The program should do the following with the data:
Calculate the average rainfall for the year.
Determine which month had the lowest amount of rainfall.
Determine which month had the highest amount of rainfall.
Sort the array of rainfall in descending order (highest rainfall first) using a bubble sort.
Neatly display the average, minimum, and maximum rainfall. Be sure to display the month of
the minimum and maximum rainfalls. Then display a table of month and rainfall amount from
the sort that you did earlier. Each of the monthly rainfall, average, minimum, and maximum
rainfalls should be displayed to two decimal places.
You will not be given a sample program for this assignment. You have already done a similar program for
reading in values from a file and finding averages, minimums, and maximums. The most difficult part of
the assignment will be to display the correct months with the correct rainfall values after you have
sorted them. I would suggest using parallel arrays for rainfall and months and every time you swap array
indices for rainfall, you do the same swap for the months.
Make sure you use good programming style. This includes commenting all your variables and
commenting through your code. Comments should explain why you are doing something. Use good
indentation (see my examples and the books examples for demonstration of good indentation). Make
sure variable names are self-documenting. Make good use of white space. Group logical sections
together with one blank line between logical sections.
Your output should be neat and pleasant to read.
Make sure you follow the specifications. If you must, you can add to the program, but do not change the
specifications in doing so.
Name your file PA4_lastName_firstName.cpp, replacing lastName with your actual last name and
firstName with your actual first name. Failure to properly name your file results in loss of points.
COSC 1436
Programming Assignment 4
Below is possible output for a sample run for this programming assignment:
Monthly Rainfall for Fort Worth, TX 2014
Minimum: September 0.06
Maximum: August 4.34
Monthly Average for Year: 1.77
Sorted by Total Rainfall
Month Inches
August 4.34
May 3.40
June 3.26
November 2.13
October 2.09
April 1.74
March 1.45
December 1.13
July 0.98
February 0.41
January 0.33
September 0.06
make sure to Sort the array of rainfall in descending order (highest rainfall first) using a bubble sort

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 Programming Questions!