Question: I need to edit follwing code therefore For the maximum and minimum rainfall amount, also display the month where that happened. For example: Maximum rainfall:
I need to edit follwing code therefore
For the maximum and minimum rainfall amount, also display the month where that happened. For example:
Maximum rainfall: January, 88.2 inches
Minimum rainfall: July, 12.3 inches
Format all numbers with 1 decimal points
import java.util.*; public class rainFall { public static void main(String[]args){ Scanner keyboard = new Scanner(System.in); final int size = 12; double[] rainFall= new double[size]; for (int i = 0; i < size; i++){ System.out.printf("Enter the rainfall amount for month %d: ", i + 1); rainFall[i]=keyboard.nextDouble(); } System.out.printf("Maximum rainfall: %.1f ",findMax(rainFall)); System.out.printf("Minimum rainfall: %.1f ",findMin(rainFall)); System.out.printf("Total rainfall: %.1f ",findSum(rainFall)); System.out.printf("Average rainfall: %.1f ",findAvg(rainFall)); keyboard.close(); } public static double findMax(double[]array){ double max = array[0]; for (int i=1; i< array.length; i++){ if (array[i]>max) max= array[i]; } return max; } public static double findMin(double[]array){ double min = array[0]; for (int i=1; i< array.length; i++){ if (array[i] Standard Input 1.29 6.68 2.37 3.46 5.15 1.74 6.53 2.52 3.31 1.17 5.53 6.01
Required Output
Enter the rainfall amount for month 1: Enter the rainfall amount for month 2: Enter the rainfall amount for month 3: Enter the rainfall amount for month 4: Enter the rainfall amount for month 5: Enter the rainfall amount for month 6: Enter the rainfall amount for month 7: Enter the rainfall amount for month 8: Enter the rainfall amount for month 9: Enter the rainfall amount for month 10: Enter the rainfall amount for month 11: Enter the rainfall amount for month 12: Maximum rainfall: February, 6.7 inches Minimum rainfall: October, 1.2 inches Total rainfall: 45.8 inches Average rainfall: 3.8 inches
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
