// 11/4/2019 // introduce array syntax // solve grades problem with arrays // (return to the employee pgm and put in arrays) import java.util.Scanner; public class GradesArray { /** read in a list of grades, and print the maximum*/ public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int SIZE = 5; int[] grades = new int[SIZE]; // declares an array with SIZE ints // all values are zero // how do I access an element in the array? // use square brackets (2 meanings to square brackets) System.out.println("0th loc is: " + grades[0]); grades[0]=88; System.out.println("0th loc is: " + grades[0]); // reading a value into a loc in an array System.out.println("Enter a grade for loc 1: " ); grades[1] = sc.nextInt(); // Since grades is an object, we can use the DOT operator // and retrieve its length, which is its capacity //for (int i=0; i max) // compare each element to max max = grades[i]; } // fall out of loop, print max System.out.println("max in array is: " + max); // outside of loop, initialize sum to zero int sum = 0; // begin loop at element 0 for (int i=0; iaverage) count++; } System.out.println(count + " elts are bigger than average."); // Enhanced for loop (no need for index i, just // process each elt in the array // general form: for (datatype elt : arrayname) for (int grade : grades) { // for every grade in grades System.out.println("in enhanced for loop, grade " + "= " + grade); } // array intialization int[] numbers = {55, 66, 77, 88, 99}; System.out.println(numbers[0]); } }