Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi, please help me with this Java code. Thanks Write a program that calculates the average rainfall for three months. The program should ask the
Hi, please help me with this Java code. Thanks
Write a 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.
NOTE: You MUST use the Scanner class to read input from the us
AverageRainfallProjectjava 3 2 import java.util.Scanner; 4 public class AverageRainfallProject 5 public static void main (String [] args) 6 7 8 9 Scanner scanner new Scanner (System.in); double sum-0.0; double average-0.0; String month1, month2, month3; double rainl, rain2,rain3; 10 12 14 15 16 17 18 19 20 System.out.println( "Enter the name of the month 1: "); month1 = scanner.nextLine(); System.out.println("Enter the rainfall (in inches): "); rain1- scanner.nextDoublek System.out.println("Enter the name of the month 2: "); month2scanner.nextLine() System.out.println("Enter the rainfall (in inches): "); rain2 scanner.nextDouble(); System.out.println( "Enter the name of the month 3: "); month3 scanner.nextLine(); System.out.println("Enter the rainfall (in inches): "); rain3scanner.nextDouble(); 23 24 25 26 27 28 29 30 31 32 average -(double)(rain1+ rain2+ rain3)/3; System.out.println("The average rainfall for " monthl + "," + month2and"month3 is"average)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started