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
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