Question: Hi, I'm currently writing in Java and stuck trying to print out the Month that had the most snow:. I can get the max value

Hi,

I'm currently writing in Java and stuck trying to print out the "Month that had the most snow:". I can get the max value of inches to print, but i need the month not the inches to print. cant figure out how to go from getMaxValue(inches) to String[] months.

package snowfall; import java.util.stream.*; import java.util.Scanner;

public class SnowFall {

public static void main(String[] args) { int Year = 2017; int[] inches = {72, 84, 43, 5, 2, 1, 1, 0, 1, 7, 93, 189}; String[] months = {"Jan", "Feb", "Mar", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"};

//finding the sum of Temp int sum = IntStream.of(inches).sum(); //Finding the average value double total = 0; // Initialize accumulator double average; // Will hold the average for (int i = 0; i < inches.length; i++) total += inches[i]; average = total / inches.length; //finding the highest value //int highest = inches[0]; //for (int index = 0; index < inches.length; index ++) //if (inches[index] > highest) // highest = inches [index]; getMaxValue(inches); //System.out.println(getMaxValue(inches[])); System.out.println("******* Aomori City, Tohoku , Japan******"); System.out.println("*******2017 Snowfall Information********"); System.out.println("Total snowfall:" + sum); System.out.println("Average snowfall: " + average); System.out.println("Month that had the most snow: " + XXXXXXX); }

public static int getMaxValue(int[] inches) { int maxValue = inches[0]; for (int i = 1; i < inches.length; i++) { if (inches[i] > maxValue) { maxValue = inches[i]; } } return maxValue;

}

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!