Design a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterte twelve times, onece for each month. Each itertion of the inner loop will ask the user for the inches of rainfall for tht month. After all iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period. Needed for C++
Screenshot of the code with explanation:


The Screenshot of the input/output:

The Code Used:
#include<iostream>
using namespace std;
int main()
{
int i,j,years,months; //variables to store the number
of months and years.
double totalRain,average,rain; //variables to store
the total ammount of rainfall, average rainfall and the rain.
cout<<"Enter the number of years: "; //Taking
the number of years as input.
cin>>years;
totalRain = 0.0; //Initializing to totalRain to
0.
for(i=1;i<=years;i++) //Outer looper iterates
for
{
cout<<"Enter the details of
rainfall for year "<<i<<endl; //Taking the rainfall for
1 year at a time.
for(j=1;j<=12;j++) //The inner
loop iterates for 12 times one for each months.
{
cout<<"Enter the raifall for "<<j<<" month: ";
//taking the rainfall for a particular month in an year.
cin>>rain;
totalRain =
totalRain + rain; //adding the rainfall to the total
rainfall.
months++;
//incrementing the number of months.
}
}
average = totalRain/months; //calculating the
average.
//printing the gathered details.
cout<<"The total number of months:
"<<months<<endl;
cout<<"The total Rainfall:
"<<totalRain<<endl;
cout<<"The average Rainfall per month:
"<<average;
return 0;
}
I hope you like the solution. In case of any doubts regarding the solution feel free to ask it in the comment section. If you like the solution please give a thumbs up.
Design a program that uses nested loops to collect data and calculate the average rainfall over...
Average Rainfall Design a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of...
Write them in python IDLE *****
5. Average Rainfall
Write a program that uses nested loops to collect data
and calculate the average rainfall over a period of years. The
program should first ask for the number of years. The outer loop
will iterate once for each year. The inner loop will iterate twelve
times, once for each month. Each iteration of the inner loop will
ask the user for the inches of rainfall for that month. After all
iterations,...
***** JAVA ONLY ***** Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. Frist the program should ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the...
Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should prompt the user for the number of years. Be sure to ask for each months average rainfall for each year. The outer loop will iterate once for each year while the inner loop will iterate 12 times(one time per month) prompting for the months average rainfall on each iteration. Display the number of months, the total inches...
5. Create a java application that uses nested loops to collect data and calculate the average rainfall over a peniod of years First the program should ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month, the program should display the number of months, the total...
Small Basic Programming Question: Average score Write a program that uses loops to collect data and calculate the average score over a number of tests for a number of students. The program should : 1. first ask the user to enter the number of students in the range of 1 to 10. 2. then the program asks the user to enter the number of tests (in the range of 1 to 5) 3. Then use a loop to collect the...
Small Basic Programming Question: Average Score- Write a program that uses loop to collect data and calculate the average score over a number of tests for a number of students. The program should: 1. first ask the user to enter the number of students in the range of 1 to 10. 2. then the program asks the user to enter the number of tests (in the range of 1 to 5) 3. Then use a loop to collect the scores...
PYTHON PROGRAMMING - CODE THE PROGRAM BASED ON THE
INSTRUCTIONS AND ALGORITHM PROVIDED
home / study / engineering / computer science / questions and
answers / python programming - code the program based on ...
Your question has been answered! Rate it below.
Let us know if you got a helpful answer.
Question: PYTHON PROGRAMMING - CODE THE PROGRAM BASED ON
THE...
Bookmark
PYTHON PROGRAMMING - CODE THE PROGRAM BASED ON THE
INSTRUCTIONS AND ALGORITHM PROVIDED
Rainfall Algorithm
Declare and...
Write a Java program that calculates the average rainfall for three months. The program should ask the user to enter the name of each month such as June or July, and the amount of rain (in inches) that fell each month. The program should display a message similar to the following: The average rainfall for June, July, and August is 6.72 inches
In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...