import uwcse.io.Input; public class OneDArrayExample { public static void main(String[] args) { // input 10 integers (e.g. grades) // store the values in an array // find the maximum value, the minimum value, and // the average int n; Input in = new Input(); do { n = in.readInt("Number of grades: "); } while (n < 1); int[] grades = new int[n]; // get the grades // grades.length gives the size of the array for (int i = 0; i < grades.length; i++) { grades[i] = in.readInt("Enter a grade: "); } // find the maximum and minimum values, and the average int max = grades[0]; int min = grades[0]; int sum = grades[0]; for (int i = 1; i < grades.length; i++) { if (grades[i] > max) { max = grades[i]; } if (grades[i] < min) { min = grades[i]; } sum += grades[i]; } System.out.println("Max = " + max); System.out.println("Min = " + min); System.out.println("Average = " + (double) sum / grades.length); } }