Friday, December 01, 2006

Calc. Average temperature example

public class CompleteTemperatureExample {
public static void main(String[] args) {

double []temp1 = new double[7];
double temp2[] = {39.0,39.5, 26, 28};


double total=0;

for (int i=0;i<temp2.length;i++){
total+=temp2[i];
} //end for

System.out.println("Average is" + total/temp2.length);

} //end main
} //end class

No comments: