Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming Rainfall Statistics Write a C++ program that reads rainfall values for each of 12 months in a year, from an external text file

C++ Programming

Rainfall Statistics

Write a C++ program that reads rainfall values for each of 12 months in a year, from an external text file starting with January and ending with December. The program then calculates and displays on the screen the total rainfall for the year, the average monthly rainfall, and the highest and lowest amounts of rainfall, with their corresponding month name. Then, all read in values and their intended month names must be displayed for checking, with a note of largest or smallest next to the corresponding value. The name (could be one or more words) of the text file must be entered at the runtime of the program. The month must be displayed in the word like January, December, etc.., but not in number like 1, 12, etc These two data files could be used as samples of data: rain equal.txt - or rain less.txt (remember any other data file similar to the two files, contains 12 decimal values for 12 months, could be used to test)

Sample of what It should look like.

The program reads rainfall values for each of 12 months in a year,

from an external text file starting with January and ending with December,

into an array of doubles. The program then calculates and displays on screen

the total rainfall for the year, the average monthly rainfall,

and the months with the highest and lowest amounts.

The read in values and their intended months were displayed at the end

(with a note of largest or smallest next to the corresponding value).

The name of the text file must be entered at the runtime

Enter the filename for rainfall data (or -1 to quit): gh

The file could not be opened ...

Enter the filename for rainfall data (or -1 to quit): rain less.txt

The total: 25.54 inches.

The average: 2.13 inches.

The largest: 4.76 inches in July

The smallest: 0.37 inches in March

Month Rainfall

===== ========

January 1.45

February 2.37

March 0.37 (smallest)

April 1.19

May 1.23

June 2.18

July 4.76 (largest)

August 2.59

September 0.87

October 1.67

November 3.77

December 3.09

Run the program again (y/n)? y

The program reads rainfall values for each of 12 months in a year,

from an external text file starting with January and ending with December,

into an array of doubles. The program then calculates and displays on screen

the total rainfall for the year, the average monthly rainfall,

and the months with the highest and lowest amounts.

The read in values and their intended months were displayed at the end

(with a note of largest or smallest next to the corresponding value).

The name of the text file must be entered at the runtime

Enter the filename for rainfall data (or -1 to quit): rain equal.txt

The total: 69.50 inches.

The average: 5.79 inches.

The largest: 13.60 inches in April, August

The smallest: 1.30 inches in March, June, November

Month Rainfall

===== ========

January 7.80

February 8.90

March 1.30 (smallest)

April 13.60 (largest)

May 10.20

June 1.30 (smallest)

July 1.70

August 13.60 (largest)

September 6.20

October 1.90

November 1.30 (smallest)

December 1.70

Run the program again (y/n)? -1

Please answer with 'y' for (yes) or 'n' for (no):

Please answer with 'y' for (yes) or 'n' for (no): y

The program reads rainfall values for each of 12 months in a year,

from an external text file starting with January and ending with December,

into an array of doubles. The program then calculates and displays on screen

the total rainfall for the year, the average monthly rainfall,

and the months with the highest and lowest amounts.

The read in values and their intended months were displayed at the end

(with a note of largest or smallest next to the corresponding value).

The name of the text file must be entered at the runtime

Enter the filename for rainfall data (or -1 to quit): -1

As you wanted to stop the program, press key to do so.

GOOD BYE!

Programmer: David

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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago