Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago