Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args){
- Scanner scanner = new Scanner(System.in);
- int years;
- int rainfallPerMonth;
- int sumRainfall = 0;
- System.out.print("Enter the number of years: ");
- years = scanner.nextInt();
- for (int i = 0; i < years; i++)
- {
- for (int y = 1; y <= 12; y++)
- {
- System.out.print("Insert inches of rainfall for month " + y + ": " );
- rainfallPerMonth = scanner.nextInt();
- sumRainfall += rainfallPerMonth;
- }
- }
- System.out.println("Number of months: " + (years * 12));
- System.out.println("Total inches of rainfall: " + sumRainfall);
- System.out.println("Average rainfall per month: " + (sumRainfall / (years * 12)));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment