Write a program weather.cpp that uses a structure to store the following weather data for a particular quarter: • Total Rainfall Low Temperature • High Temperature Average Temperature (average of low and high temperature) The program should have an array of structures with a size of four (4) to hold weather data for an entire year. When the program runs, it should ask the user to enter data for each quarter. Once the data are entered for all the quarters, the program should calculate and display the average quarter rainfall, the total rainfall for the year, the highest and lowest temperatures for the year (and the quarter they occurred in), and the average of all the quarterly average temperatures. Input validation: Only accept temperatures within the range between -100 and + 140 degrees Fahrenheit, and the low temperature must not be higher than the high temperature.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Instructions
Write a program weather.cpp that uses a structure to store the following weather data for a
particular quarter:
• Total Rainfall
Low Temperature
High Temperature
Average Temperature (average of low and high temperature)
The program should have an array of structures with a size of four (4) to hold weather data for an
entire year. When the program runs, it should ask the user to enter data for each quarter. Once
the data are entered for all the quarters, the program should calculate and display the average
quarter rainfall, the total rainfall for the year, the highest and lowest temperatures for the year
(and the quarter they occurred in), and the average of all the quarterly average temperatures.
Input validation: Only accept temperatures within the range between -100 and + 140 degrees
Fahrenheit, and the low temperature must not be higher than the high temperature.
Notes
• Validate temperatures within the range between -100 and + 140 degrees.
• Validate the low temperature must not be higher than the high temperature.
• You are encouraged to write the function to display the output results. Suggested function
prototype: void displayAverages (WeatherInfo year[], int nQuarter);
• You are encouraged to write the function to compute the lowest and highest temperatures and
their corresponding indexes of quarters (which will be called in displayAverages).
Suggested function prototype:
Transcribed Image Text:Instructions Write a program weather.cpp that uses a structure to store the following weather data for a particular quarter: • Total Rainfall Low Temperature High Temperature Average Temperature (average of low and high temperature) The program should have an array of structures with a size of four (4) to hold weather data for an entire year. When the program runs, it should ask the user to enter data for each quarter. Once the data are entered for all the quarters, the program should calculate and display the average quarter rainfall, the total rainfall for the year, the highest and lowest temperatures for the year (and the quarter they occurred in), and the average of all the quarterly average temperatures. Input validation: Only accept temperatures within the range between -100 and + 140 degrees Fahrenheit, and the low temperature must not be higher than the high temperature. Notes • Validate temperatures within the range between -100 and + 140 degrees. • Validate the low temperature must not be higher than the high temperature. • You are encouraged to write the function to display the output results. Suggested function prototype: void displayAverages (WeatherInfo year[], int nQuarter); • You are encouraged to write the function to compute the lowest and highest temperatures and their corresponding indexes of quarters (which will be called in displayAverages). Suggested function prototype:
void computeMinMax (WeatherInfo year [), int nQuarter,
double& highest, double& lowest,
int& highQuarter, int& lowQuarter);
• Copy and paste your console outputs after the end of your source file. Remember to comment
the output with /* and */ or multiple //.
• Avoid cryptic variable names and poor indentations.
• Your code must compile using the IDE and compiler the instructor specifies. Any code that does
not compile and run in the environment specified by the instructor will get a zero.
Sample Output
Enter the total rainfall, low & high temperatures:
Quarter 1: 15 40 67
Quarter 2: 40 50 78
Quarter 3: 30 58 80
Quarter 4: 5 -110 85
ERROR: Temperature range: -100 through 140
Low temperature <= high temperature.
Please enter low and high temperatures again: 65 141
ERROR: Temperature range: -100 through 140
Low temperature <= high temperature.
Please enter low and high temperatures again: 140 65
ERROR: Temperature range: -100 through 140
Low temperature <= high temperature.
Please enter low and high temperatures again: 65 85
Total Rainfall: 90
Average Quarterly Rain: 22.5
Average Quarterly Average Temperature: 65.375
Highest Temperature: 85 (Quarter 4)
Lowest Temperature: 40 (Quarter 1)
Transcribed Image Text:void computeMinMax (WeatherInfo year [), int nQuarter, double& highest, double& lowest, int& highQuarter, int& lowQuarter); • Copy and paste your console outputs after the end of your source file. Remember to comment the output with /* and */ or multiple //. • Avoid cryptic variable names and poor indentations. • Your code must compile using the IDE and compiler the instructor specifies. Any code that does not compile and run in the environment specified by the instructor will get a zero. Sample Output Enter the total rainfall, low & high temperatures: Quarter 1: 15 40 67 Quarter 2: 40 50 78 Quarter 3: 30 58 80 Quarter 4: 5 -110 85 ERROR: Temperature range: -100 through 140 Low temperature <= high temperature. Please enter low and high temperatures again: 65 141 ERROR: Temperature range: -100 through 140 Low temperature <= high temperature. Please enter low and high temperatures again: 140 65 ERROR: Temperature range: -100 through 140 Low temperature <= high temperature. Please enter low and high temperatures again: 65 85 Total Rainfall: 90 Average Quarterly Rain: 22.5 Average Quarterly Average Temperature: 65.375 Highest Temperature: 85 (Quarter 4) Lowest Temperature: 40 (Quarter 1)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY