Question: IN C + + PLEASE Solving the Weather Statistics Problem This assignment will solve a problem using weather statistics Part I - Understand Weather Statistics

IN C++ PLEASE
Solving the Weather Statistics Problem
This assignment will solve a problem using weather statistics
Part I - Understand Weather Statistics Problem (50 pts)
The Question # 4 in Gaddis book chapter 11 illustrate a solution for how to solve the weather statistics
problem. You can read it in chapter 11. I am copy the original code here for your reference.
Weather Statistics
Write a program that uses a structure to store the following weather data
for a particular month:
Total Rainfall
High Temperature
Low Temperature
Average Temperature
The program should have an array of 12 structures to hold weather data
for an entire year. When the program runs, it should ask the user to enter
data for each month. (The average temperature should be calculated.)
Once the data are entered for all the months, the program should
calculate and display the average monthly rainfall, the total rainfall for
the year, the highest and lowest temperatures for the year (and the
months they occurred in), and the average of all the monthly average
temperatures.
Input Validation: Only accept temperatures within the range between -100 and
+140 degrees Fahrenheit.
Get this program done and save your file as weatherStatisticFNameLName.cpp. There is a video
note in the book to help you to get this done. Copy and paste a set of output at the end of
program will well descripted labels. This label should clearly indicate that this is the original
problem solution.
Part II - Modify the Weather Statistics Program I (20 pts)
Do the programming challenge question #5 and copy/past a set of sample output at the end of program.
In this set of out put you will clearly indicate that this run is from Part II and the line numbers of the
source code that include your modifications (as comments). No partial credit given to this part. You will
either get 20 points (for follow the instructions strictly) or get 0 points. The instruction is given in the text
book. I put a copy here for your reference.
Weather Statistics Modification
Modify the program that you wrote for Programming Challenge 4
(weather statistics) so it defines an enumerated data type with
enumerators for the months (JANUARY, FEBRUARY, so on). The
program should use the enumerated type to step through the elements of
the array.
Part III - Modify the Weather Statistics Program II (30 points)
Modify the Weather Statistics program so it will do the following:
Prompt user only for the Total Rainfall for each month.
Generate random number for the "High Temperature" and "Low Temperature" in each month.
But the Tricky is that the random number must be reasonable. Look at the following table for
some unreasonable data generated from the rand() function:
here is the program #include
#include
#include
using namespace std;
// Constant for the number of months
const int NUM_MONTHS =12;
// Declaration of the WeatherInfo structure
struct WeatherInfo
{
double rain; // Total rainfall
double high; // High temperature
double low; // Low temperature
double averageTemp; // Average temperature
};
int main()
{
// Create an array of WeatherInfo structures
WeatherInfo year[NUM_MONTHS];
int index =0;
// Get the weather data for each month.
cout "Enter the following information:
";
for (index =0; index NUM_MONTHS; index++)
{
// Get the rainfall.
cout "Month "(index +1) endl;
cout "\tTotal Rainfall: ";
cin >> year[index].rain;
// Get the high temperature.
cout "\tHigh Temperature: ";
cin >> year[index].high;
// Validate the high temperature.
while (year[index].high -100|| year[index].high >140)
{
cout "ERROR: Temperature must be in the range "
"of -100 through 140.
";
cout "\tHigh Temperature: ";
cin >> year[index].high;
}
// Get the low temperature.
cout "\tLow Temperature: ";
cin >> year[index].low;
// Validate the high temperature.
while (year[index].low -100|| year[index].low >140)
{
cout "ERROR: Temperature must be in the range "
"of -100 through 140.
";
cout "\tLow Temperature: ";
cin >> year[index].low;
}
// Calculate the average temperature.
year[index].averageTemp =
(year[index].high + year[index].low)/2.0;
}
// Calculate total annual rainfall
double totalRain =0;
for (index =0; index NUM_MONTHS; index++)
totalRain += year[index].rain;
// Calculate average monthly rainfall
double aveMonthRain = totalRain / NUM_MONTHS;
// Calculate the average monthly average temperature
double aveTotal =0, aveAve;
for (index =1; index NUM_MONTHS; index++)
aveTotal += year[index].averageTemp;
aveAve = aveTotal / NUM_MONTHS;
// Find the highest & lowest temperatures
double highest, lowest, highMonth =0, lowMonth =0;
highest = year[0].high;
lowest = year[0].low;
for (index =1; index NUM_MONTHS; into part 1:
IN C + + PLEASE Solving the Weather Statistics

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 Programming Questions!