Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a Java program. The program must determine in what months there was the

ID: 657951 • Letter: T

Question



This is a Java program. The program must determine in what months there was the highest and lowest high, and in what months was the highest and lowest low, and in what months was the highest and lowest range. the calculation of the average, highest, and lowest must each be a separate method. Average, highest, and lowest methods must each take one array as the input. The picture I posted above is how the output should look like and the second picture shows the values you can input. There should be two loops, one for input and one for the calculation and output. The months should also be in an array.

This program calculates and prints average monthly temperatures Enter the zipcode Enter the average high for January Enter the average low for January Enter the average high for February Enter the average low for February Enter the average high for March Enter the average low for March Enter the average high for April Enter the average low for April Enter the average high for May Enter the average low for May Enter the average high for June Enter the average low for June Enter the average high for July Enter the average low for July Enter the average high for August Enter the average low for August Enter the average high for September Enter the average low for September Enter the average high for October Enter the average low for October Enter the average high for November Enter the average low for November Enter the average high for December Enter the average low for December

Explanation / Answer

public class calculate
{

public static void highest_high(int[] h,String[] m)
{
int highest=h[0];
int flag=0;
for(int i=1;i<h.length;i++)
{
if(highest<h[i])
{
flag=i;
highest=h[i];
}
}
System.out.println( "highest high temperature is " + highest + "in " + m[flag] + " month ");
}

public static void highest_low(int[] h,String[] m)
{
int lowest=h[0];
int flag=0;
for(int i=1;i<h.length;i++)
{
if(lowest>h[i])
{
flag=i;
lowest=h[i];
}
}
System.out.println( "highest low temperature is " + lowest + "in " + m[flag] + " month ");
}

public static void lowest_high(int[] l,String[] m)
{
int highest=l[0];
int flag=0;
for(int i=1;i<l.length;i++)
{
if(highest<l[i])
{
flag=i;
highest=l[i];
}
}
System.out.println( "lowest high temperature is " + highest + "in " + m[flag] + " month ");
}

public static void lowest_low(int[] l,String[] m)
{
int lowest=l[0];
int flag=0;
for(int i=1;i<l.length;i++)
{
if(lowest>l[i])
{
flag=i;
lowest=l[i];
}
}
System.out.println( "lowest low temperature is " + lowest + "in " + m[flag] + " month ");
}

public static void average(int[] high,int[] low)
{
int high_avg,low_avg;
int sum_high=0,sum_low=0;
for(int i=0;i<high.length;i++)
{
sum_high+=high[i];
}
high_avg=(float)sum_high/12.0;
for(int i=0;i<low.length;i++)
{
sum_low+=low[i];
}
low_avg=(float)sum_low/12.0;
System.out.println( "Average high temperature is" + high_avg);
System.out.println( "Average low temperature is " + low_avg);
}

public static void main(String args[])
{
int[] high={41,40,51,60,75,82,89,88,78,70,59,50};
int[] low={10,18,35,41,60,68,70,72,65,55,40,30};
String[] months={"January","february","March","April","May","June",
"July","August","September","October","November","December"};
highest_high(high,months);
highest_low(high,months);
lowest_high(low,months);
lowest_low(low,months);
average(high,low);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote