Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program is about weather statistics. Write a program that uses a structure to store the following data for the purpose of a research in

This program is about weather statistics.

Write a program that uses a structure to store the following data for the purpose of a research in meteorology:

  • Year (2017, 2018, 2019, 2020)
  • First-Quarter Rain Amount
  • Second-Quarter Rain Amount
  • Third-Quarter Rain Amount
  • Fourth-Quarter Rain Amount
  • Total Annual Rain Amount
  • Average Quarterly Rain Amount

Requirements:

  1. The program should make use of 4 variable of the structure. Each variable represents one of the years (2017, 2018, etc.)
  2. The user should be asked to enter the four quarter's rain amount for each year.
  3. Each year's total and average rain amount should be calculated and stored in the appropriate member of each structure variable.
  4. The results should then be displayed on the screen.

Input validation: Negative numbers for the rain amount should not be accepted

this is what i have so far and not sure what i am missing to seperate line for each answer entered and to add annual and quarterly questions :

//Weather statistics #include #include using namespace std; // Declaration of WeatherStatistics struct WeatherStatistics { const int NUM_YEAR = (2017, 2018, 2019, 2020); double First_Quarter_Rain_Amount; double Second_Quarter_Rain_Amount; double Third_Quarter_Rain_Amount; double Fourth_Quarter_Rain_Amount; double Total_Annual_Rain_Amount; double Average_Quarterly_Rain_Amount; }; // Function Prototypes void getYearData(WeatherStatistics&);

double First_Quarter_Rain_Amount(WeatherStatistics[], int); double Second_Quarter_Rain_Amount(WeatherStatistics[], int); double Third_Quarter_Rain_Amount(WeatherStatistics[], int); double Fourth_Quarter_Rain_Amount(WeatherStatistics[], int); double Total_Annual_Rain_Amount(WeatherStatistics[], int, int &); double Average_Quarterly_Rain_Amount(WeatherStatistics[], int, int&);

int main() { //constant for year const int NUM_YEAR = (2017, 2018, 2019, 2020);

string Year_2017, Year_2018, Year_2019, Year_2020;

float First_Quarter_Rain_Amount_Year, Second_Quarter_Rain_Amount_Year, Third_Quarter_Rain_Amount_Year, Fourth_Quarter_Rain_Amount_Year, Total_Annual_Rain_Amount_Year, Average_Quarterly_Rain_Amount_year, total, average;

//ask user to enter rain amounts cout << endl; cout << " This program calculates the average"; cout << " rainfall for each quarter and year." << endl; cout << " Press Enter to continue." << endl; cin.get();

// information cout << "Enter the year for Weather statistics : "; cin >> Year_2017, Year_2018, Year_2019, Year_2020; cout << "Enter first quarter rain amount "; cout<< ":"; cout << "Enter second quarter rain amount"; cout << ": "; cout << " Enter third quarter rain amount"; cout << ": "; cout << "Enter fourth quarter rain amount"; cout << ": "; cin >> Total_Annual_Rain_Amount_Year;

//calculate total and average total= Total_Annual_Rain_Amount_Year; average = Total_Annual_Rain_Amount_Year, First_Quarter_Rain_Amount_Year, Second_Quarter_Rain_Amount_Year, Third_Quarter_Rain_Amount_Year, Fourth_Quarter_Rain_Amount_Year; cout<< endl; return 0;

}

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

U11 Informing Industry: Publicizing Contract Actions 317

Answered: 1 week ago

Question

LO3.3 Describe supply and explain how it can change.

Answered: 1 week ago

Question

LO3.1 Characterize and give examples of markets.

Answered: 1 week ago