Question: Write a C++ program that calculates both the weekly and the monthly average temperatures for your area. To start, please create a text file (named

Write a C++ program that calculates both the weekly and the monthly average temperatures for your area.

To start, please create a text file (named temperatures.txt) that contains 4 lines (rows) of 7 daily average temperatures (in F or C degrees). Then, create a C++ program that:

reads weekly temperature data from the .txt file (7 temperatures per week); displays the data; and calculates and displays the weekly average of those temperatures, and

calculates and displays the monthly average of all of the 28 temperatures.

In creating this program, the following programming elements could be useful: (a) a 1-dimensional array(that stores the 7 temperatures for each week, from the .txt file), and (b) 2 nested For loops.

A sample run of dataand the requested screen displaymight be as follows (user input in bold):

temperatures.txt file contains the following data (you must first create this file):

76 77 72 76 79 81 79

78 82 85 82 80 83 81

82 79 80 84 82 85 87

85 81 82 78 79 83 85

Screen display and output:

Weekly & Monthly Average Temperature Calculator

----------------------------------------------------------------

The 7 daily temperatures for week 1 are: 76 77 72 76 79 81 79

The weekly average temperature for week 1 is: 77.1

The 7 daily temperatures for week 2 are: 78 82 85 82 80 83 81

The weekly average temperature for week 2 is: 81.6

The 7 daily temperatures for week 3 are: 82 79 80 84 82 85 87

The weekly average temperature for week 3 is: 82.7

The 7 daily temperatures for week 4 are: 85 81 82 78 79 83 85

The weekly average temperature for week 4 is: 81.9

Based on these values, the monthly average temperature is: 80.8

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!