Asked • 21d

MyProgrammingLab (PEARSON). Chapter 3 - Ex. 70111. Average Rainfall.

Average Rainfall

Write a program that calculates the average rainfall for three months. The program should ask the user to enter the name of a data file that that contains rainfall data for three months. The file consists of three lines, each with the name of a month, followed by one or more spaces, followed by the rainfall for that month. The program opens the file, reads its contents and then displays a message like:

     The average rainfall for June, July, and August is 6.72 inches.

Prompts And Output: The program prompts the user with the string "Enter filename with monthly data: ". The output should be of the form: "The average rainfall for MONTH1, MONTH2, and MONTH3 is: AVERAGE" where MONTH1, MONTH2, and MONTH3 are the month names that were read from the datafile user and where AVERAGE is the average rainfall calculated from the file's rainfall data and shown with exactly two digits past the decimal point.

1 Expert Answer


Oswald M. answered • 21d

4.9 (66)

COP 1334 - Starting Out with C++ Early Objects, 10th Ed. PEARSON.

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.