Question: **This program is for C++** Write a program that defines a struct WeatherType to store the following weather data for a particular month: Month Name
**This program is for C++**
Write a program that defines a struct WeatherType to store the following weather data for a
particular month:
Month Name
Rainfall
High Temperature
Low Temperature
Average Temperature
The month name is a string. All other data are floating-point values. The program should have an
array of struct of 12 elements to hold weather data for 12 months of a year. When the program runs,
it should read the rainfall, high temperature, and low temperature of each month from a text file
hw3data.txt(information down below) and store the data in an array of struct. The average temperature of each month
should be calculated from the high temperature and low temperature of that month.
Your program should perform the following tasks:
A. Display the month name, rainfall, high temperature, low temperature, and average temperature of
each month in a neat format on the screen.
The program should also calculate and display the following information:
B. The total rainfall of the year
C. The average monthly rainfall for the year
D. The highest temperature of the year and the corresponding month name
E. The lowest temperature of the year and the corresponding month name
F. The average annual temperature, i.e., the average of the monthly average temperatures.
You should write five functions to perform task A, B, D, E, and F, but not task C (since the average
monthly rainfall can be easily calculated from the total rainfall). You have freedom to decide what
parameters to be passed into the functions and what value(s) to be returned from the functions. But
the output statements must be in the main function except the function for task A.
The input data in the text file is arranged like so:
Jan 5.34 38.3 26.9 Feb 2.33 41.6 28.9 Mar 3.64 49.7 35.2 Apr 5.12 61.2 44.8 May 9.10 70.8 54.0 Jun 2.50 79.3 63.6 Jul 3.51 84.1 68.8 Aug 12.36 82.6 67.8 Sep 2.24 75.2 60.8 Oct 6.38 63.8 50.0 Nov 2.82 53.8 41.6 Dec 5.58 43.0 32.0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
