Question: JAVA /** * This method adds rainfall values to the array. Using a while loop * - present the message, e.g. Please enter an integer

JAVA

/** * This method adds rainfall values to the array. Using a while loop * - present the message, e.g. "Please enter an integer for the rainfall data for January or enter x to stop" * - get the input from the console, if it is "x" then the loop stops and false is returned. Otherwise store the integer value in the array * - end the loop when 12 integers have been added to the array, return true. * * @return true if a value was given for all 12 months, return false use enter x to stop */ public static boolean addRainfallData() { String [] months= {"january", "march"}; Scanner scan = new Scanner(System.in); int i=1; while(i<=12) { System.out.println("Please enter an integer for the rainfall data for " + months[0] + " or enter x to stop:"); int num=scan.nextInt(); i++; } return false; }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!