You are on page 1of 1

//Average Rainfall

//This takes input from the keyboard, adds it and then divides by three for an average.

import java.io.*;
import java.util.*;

public class rainTest{


public static void main(String [] args){
Scanner sc = new Scanner(System.in);

int april, may, june, average,total;//Declares

System.out.println("Rainfall for April:");


april = sc.nextInt();//accepts value for april

System.out.println("Rainfall for May:");


may = sc.nextInt();//accepts value for may

System.out.println("Rainfall for June:");


june = sc.nextInt();//accepts value for June

total = (april + may + june);//adds the three months of rainfall


average =(total/3);//divides the three months to get average rainfall

System.out.println("Rainfall for April:\t" + april);

System.out.println("Rainfall for May: \t" + may);

System.out.println("Rainfall for June: \t" + june);

System.out.println("Average rainfall: \t" + (double)average);

}
}

You might also like