Howdy partners
How are you doing !!
I got a problem here and I really don't know how should I handle it ??
here the problem is :
Suppose that temperature measurements were made on 7 days of 2009 in each of 5 cities. Write a program that will read the city name followed by the temperature measurements of that city. The city name and measurements should be stored into two arrays. The program should find out the average temperature for each city. Also you should find the average temperature of each day.
I have tried so many time to understand it but NO-WAY
please I really need YOUR help
here what I wrote :
import java.util.*;
class assignment_7012606
{
public static void main(String args[])
{
int t;
String c;
String[] city=new String[5];
int[] temp=new int[35];
double avgc1,avgc2,avgc3,avgc4,avgc5,avgd1,avgd2,avgd3,av gd4,avgd5,avgd6,avgd7;
int d1,d2,d3,d4,d5,d6,d7,c1,c3,c4,c5;
Scanner s=new Scanner(System.in);
for (int i=0;i<5;i++){
System.out.println("enter the city name");
c=s.nextLine();
city[i]=c;
}
for (int a=0;a<35;a++){
System.out.println("enter the temperature");
t=s.nextInt();
temp[a]=t;
}
avgc1=temp[0][1][2][3][4][5][6];
temp[7][8][9][10][11][12][13]=avgc2;
temp[14][15][16][17][18][19][20]=avgc3;
temp[21][22][23][24][25][26][27]=avgc4;
temp[28][29][30][31][32][33][34]=avgc5;
temp[0][7][14][21][28]=avgd1;
temp[1][8][15][22][29]=avgd2;
temp[2][9][16][23][30]=avgd3;
temp[3][10][17][24][31]=avgd4;
temp[4][11][18][25][32]=avgd5;
temp[5][12][19][26][33]=avgd6;
temp[6][13][20][27][34]=avgd7;
c1=avgc1/5;
System.out.println("the average of first city is "+c1);
System.out.println("\n");
c2=avgc2/5;
System.out.println("the average of second city is "+c2);
System.out.println("\n");
c3=avgc3/5;
System.out.println("the average of third city is "+c3);
System.out.println("\n");
c4=avgc4/5;
System.out.println("the average of fourth city is "+c4);
System.out.println("\n");
c5=avgc5/5;
System.out.println("the average of fivth city is "+c5);
System.out.println("\n");
d1=avgd1/7;
System.out.println("the average of the first day"+d1);
System.out.println("\n");
d2=avgd2/7;
System.out.println("the average of the second day"+d2);
System.out.println("\n");
d3=avgd3/7;
System.out.println("the average of the third day"+d3);
System.out.println("\n");
d4=avgd4/7;
System.out.println("the average of the fourth day"+d4);
System.out.println("\n");
d5=avgd5/7;
System.out.println("the average of the fivith day"+d5);
System.out.println("\n");
d6=avgd6/7;
System.out.println("the average of the sixith day"+d6);
System.out.println("\n");
d7=avgd7/7;
System.out.println("the average of the seventh day"+d7);
}
}
so anyone can help me?