[ temperature.java ]
import java.io.*;class Statistics
{
public static double average(double intdouble[])
{
int i=0;
double sum=0;
for(i=0;i<intdouble.length;i++)
{
sum+=intdouble[i];
}
return sum/intdouble.length;
}
}
class temperature
{
public static void main(String[] args) throws IOException
{
int i=0,j=0;
double week[][];
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
week=new double[4][7];
for(i=0;i<4;i++)
{
System.out.println("Week " + (i+1) + " : ");
for(j=0;j<7;j++)
{
System.out.print("Enter Temprature Of Day " + (j+1) + " : ");
week[i][j]=Double.parseDouble(br.readLine());
}
System.out.println("");
}
System.out.println("AVERAGE TEMPRATURE : ");
for(i=0;i<4;i++)
{
System.out.println("WEEK " + (i+1) + " : " + Statistics.average(week[i]));
}
}
}
GoTo Command Prompt(Win + R)
ReplyDeleteHOW TO COMPILE
javac c:\yourdir\temperature.java
HOW TO EXECUTE
java c:\yourdir\temperature