0
I have the following code that holds an array of 7 values, each for each day of the week. then I have to create a function that sums these 7 values (successfully concluded), tells what is the highest value of this Array (successfully completed) and then indicates which day the value occurred (where the proleme is). I still have a problem with int day=rainHours.indexof(maxTempDay); where it says "cannot find Symbol - method indexof(int). I leave here the code would appreciate help.
public static void main(String[] args)
{
int [] rainHours=new int[]{1,3,0,0,6,3,8};
int sum = rainInBusyDays(rainHours);
System.out.println(sum);
int maxValue=maxRain(rainHours);
int maxTempDay=mostRainy(rainHours);
int day=rainHours.indexOf(maxTempDay);
System . out . println("O valor máximo é:" + maxValue + " no " + day + "º dia da semana ");
}
public static int rainInBusyDays(int[] rainH)
{
int total = 0;
for (int i =1; i<rainH.length-1 ;i++)
{
total =total + rainH[i];
}
return total;
}
public static int maxRain(int[] rainHo)
{
int max = 0;
for(int j=0;j<rainHo.length;j++)
{
if (rainHo[j] > max)
{
max= rainHo[j];
}
}
return max;
}
public static int mostRainy(int[] rainHou)
{
int maxTempDay = 0;
for(int k = 0 ; k<rainHou.length;k++)
{
if(rainHou[k] > maxTempDay)
{
maxTempDay = rainHou[k];
}
}
return maxTempDay;
}
So how do I call this "i" so you can give Return on the correct day to print on the main function?
– Phil
@Phil I edited my answer explaining to you how to use the
i
– Andre Gusmao