> I have an assignment to track average temps of a year in NYC and tell the averages for each month, the highest and lowest temps for the year, and print how many days were below 33F or above 75F. Below is the program that I have come up with for the averages of each month and the Highest and lowest temps. The problem is that the highs and lows are supposed to be in the format of "The hottest (coldest) day was Tuesday January 2". I can't seem to figure out how to get this to work from where I am. I tried a couple of switch statements, but didn't have much luck. I also can't seem to figure out the whole how many days were above 75 or below 33 issue either. Can anyone help.
import java.util.*; class Assignment0702 { public static void main(String args[]) { int year[]=new int[365]; int sum=0; for (int x=0; x<31; x++) {year[x] = (int)Math.floor(25+Math.random()*14); sum+=year[x]; } System.out.println("Avera ge temperature for January: " +sum/31); { int sum2=0; for (int x=31; x<59; x++) {year[x] = (int)Math.floor(26+Math.random()*15); sum2+=year[x]; } System.out.println("Aver age temperature for February: " +sum2/28); } { int sum3=0; for (int x=59; x<90; x++) {year[x] = (int)Math.floor(34+Math.random()*15); sum3+=year[x]; } System.out.println("Aver age temperature for March: " +sum3/31); } { int sum4=0; for (int x=90; x<120; x++) {year[x] = (int)Math.floor(43+Math.random()*16); sum4+=year[x]; } System.out.println("Aver age temperature for April: " +sum4/30); } { int sum5=0; for (int x=120; x<151; x++) {year[x] = (int)Math.floor(52+Math.random()*17); sum5+=year[x]; } System.out.println("Aver age temperature for May: " +sum5/31); } { int sum6=0; for (int x=151; x<181; x++) {year[x] = (int)Math.floor(62+Math.random()*16); sum6+=year[x]; } System.out.println("Aver age temperature for June: " +sum6/30); } { int sum7=0; for (int x=181; x<212; x++) {year[x] = (int)Math.floor(68+Math.random()*16); sum7+=year[x]; } System.out.println("Aver age temperature for July: " +sum7/31); } { int sum8=0; for (int x=212; x<243; x++) {year[x] = (int)Math.floor(60+Math.random()*16); sum8+=year[x]; } System.out.println("Aver age temperature for August: " +sum8/31); } { int sum9=0; for (int x=243; x<273; x++) {year[x] = (int)Math.floor(49+Math.random()*17); sum9+=year[x]; } System.out.println("Aver age temperature for September: " +sum9/30); } { int sum10=0; for (int x=273; x<304; x++) {year[x] = (int)Math.floor(41+Math.random()*14); sum10+=year[x]; } System.out.println("Ave rage temperature for October: " +sum10/31); } { int sum11=0; for (int x=303; x<334; x++) {year[x] = (int)Math.floor(31+Math.random()*13); sum11+=year[x]; } System.out.println("Ave rage temperature for November: " +sum11/30); } { int sum12=0; for (int x=334; x<365; x++) {year[x] = (int)Math.floor(47+Math.random()*15); sum12+=year[x]; } System.out.println("Ave rage temperature for December: " +sum12/31); } { int largst=year[0];
for(int x=1;x<364;x++)
if(year[x]>largst)largst=year[x];
System.out.println("Th e highest temperature="+largst); } { int smallst=year[0]; for(int x=1;x<364;x++) if(year[x]<smallst)smallst=year[x]; System.out.println("Th e lowest temperature="+smallst);