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

Could you tell me what is wrong with this program and fix it? Thank you Create a

ID: 3621687 • Letter: C

Question

Could you tell me what is wrong with this program and fix it?
Thank you
Create a program that includes an array that holds 31 integers. This array represents the high temperature for each day in a month. Request the month from the user then the temperature for each of the days (months have different number of days).
Output: the average temperature, highest temperature, lowest temperature and the difference between the warmest and coldest day.

import java.util.ArrayList;
import java.util.Scanner;
/**
* Write a description of class Temperarture here.
*
* @author ()
* @version ()
*/
public class Temperature{

// instance variables - replace the example below with your own
private ArrayList monthTemperatures;
private int month;



/**
* Constructor for objects of class Temperature
*/
public Temperature(){

// initialize instance variables
monthTemperatures = new ArrayList();
}


public void storeNumTemp(){

readMonth();
int monthdays = getNumDays(month);
monthdays=31;
System.out.println("Entered Month: " + month + " Number of days for this month: " + monthdays);
for(int i=0; i
int temperature = scanTemp();
//monthTemperatures.add(temperature);
monthTemperatures.add(i, temperature);
}
for(int temp : monthTemperatures){

System.out.println(temp);
}
System.out.println("HighesTemp: " + getHighestTemp() + " LowestTemp: " + getLowestTemp() );

}
public int getHighestTemp(){

int highestTemp = 0;
for(int i=0;i
int temp = monthTemperatures.get(i);
if(temp>highestTemp)
highestTemp = temp;
}
return highestTemp;
}

public int getLowestTemp(){

int lowestTemp = 999999999;
for(int i=0;i
int temp = monthTemperatures.get(i);
if(temp
lowestTemp = temp;
}
return lowestTemp;
}

private void readMonth(){


Scanner scan = new Scanner(System.in);{

System.out.print("Enter Month Number: ");
month = scan.nextInt();
}
}

private int getNumDays(int month){

int days=0;
switch(month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: days=31;
break;
case 2: days=28;
break;
case 4:
case 6:
case 9:
case 11: days=30;
break;
default: days=0;
}
return days;
}
private int scanTemp()
{
int dayTemp;
Scanner scan = new Scanner(System.in);
{
System.out.print("Enter day Temperature ");
dayTemp = scan.nextInt();
}
return dayTemp;

}
public void totalTemp(){
int totalTemp=0;
for(int i=0; i
totalTemp += monthTemperatures.get(i);
}
System.out.println("Average Temperature for" + month + " is:" +(totalTemp/ monthTemperatures.size()));
}

}

Explanation / Answer

Here is the program. Ill be nice. import java.util.*; public class temp { public static void main(String[] args) { Scanner in=new Scanner (System.in); int[] array = new int[31]; System.out.print("Enter Month (example: January is 1): "); int k=in.nextInt(); int days = 03; if((k == 1)||(k == 3)||(k == 5)||(k == 8)||(k == 10)||(k == 12)) { days = 31; } if((k == 4)||(k == 6)||(k == 9)||(k == 11)) { days = 30; } if(k==2) { days = 28; } //test case if(k==42) { days = 4; } System.out.println(days + " days in this month"); for(int i=0; i
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