public class ArrayOfScores
{
public static void main(String[] args)
{
int[] scores = { 3, 7, 2, 5, 4 };
int smallest, highest, temp, total = 0;
double average = 0.0;
//find the lowest score
smallest = Integer.MAX_VALUE;
for (int i = 0; i < scores.length; i++)
if (scores[i] < smallest)
smallest = scores[i];
System.out.println("\nThe lowest score is : " + smallest);
//find the highest score
highest = -Integer.MAX_VALUE;
for (int i = 0; i < scores.length; i++)
if (scores[i] > highest)
highest = scores[i];
System.out.println("\nThe highest score is : " + highest);
//find the average score
for (int i = 0; i < scores.length; i++)
total = total + scores[i];
average = (double)total/scores.length;
System.out.println("\nThe average score is : " + average);
}
}