import java.text.DecimalFormat;
import java.io.*;
import java.util.*;
public class RainFall{
public static void main(String[]
args)
{
Scanner kb=new
Scanner(System.in);
int years;
int
month=12;
double
total=0;
double average;
int
months[];
String input;
months = new
int[12];
DecimalFormat df = new
DecimalFormat("##0.00");
System.out.println("Enter the number
of years you wish to calculate. ");
input = kb.nextLine();
for(int y = 1;
y<=Integer.parseInt(input);
y++)
{
System.out.println("Enter the amount of rainfall in inches for year
#"+y+":");
years =
Integer.parseInt(input);
while (y < 1)
{
System.out.println("Do not accept a number less than 1 for the
number of years.");
}
for(int m = 1; m<=12; m++ )
{
System.out.println("Enter the amount of rainfall in inches for
month #" + m + ":");
months[m-1]=
kb.nextInt();
while (m
< 0)
{
System.out.println("Do not accept negative numbers for the monthly
rainfall.");
}
}
for(int i=0; i<12;i++)
{
total=
total+months[i];
}
System.out.println("The total amount
of rainfall for year " + y + " is " + total);
average = total/12;
System.out.println("The average of
rainfall for year " + y + " is " + average);
}
}
}
Write 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...
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...
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...
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,...
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...
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...
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...
Lab 5-2 Nested Loops 2. Summation Of Numbers (using Nested While Loops) Part A: The program will calculate and display the total of all numbers up to a specific number (entered by the user). Only positive numbers are allowed. Part B: User-controlled loop Part A Input Validation loop Part A: Summation loop Examples: When 5 is entered the program will calculate the total as 1+2+...+5 and display 15. When 2 is enterered the program will calculate the total as 1+2...
USING RAPTOR: A meteorologist needs to evaluate the average rain fall of two months. You need to create a program that asks you the name of the month and then rainfall in 4 weeks of the month and then outputs the average rainfall for that month. Hint: The outer loop allows to input two names of the month and the inner loop should accept the four numbers for the rainfall of the 4 weeks.