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 doubles from a file. Each double
represents the total rainfall in inches for the months of the year in month order. The 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 selfdocumenting. 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 PAlastNamefirstName.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
Programming Assignment
Below is possible output for a sample run for this programming assignment:
Monthly Rainfall for Fort Worth, TX
Minimum: September
Maximum: August
Monthly Average for Year:
Sorted by Total Rainfall
Month Inches
August
May
June
November
October
April
March
December
July
February
January
September
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
