/* read array data from a file; call a method to handle array value (find average, max) */ import java.util.Scanner; class MaxAvgArrayDemo { public static void main(String[] args) { Scanner input = new Scanner(System.in); double[] vals = new double[100]; int size = 0; while(input.hasNextDouble()) { vals[size] = input.nextDouble(); size ++; } System.out.print("size = " + size + "\n\n"); // invoke the method double avg = findAvg(vals, size); System.out.println("AVG = " + avg + "\n\n"); // invoke the method double max = findMax(vals, size); System.out.println("MAX = " + max + "\n\n"); // output all elements of the array to monitor outPutArray(vals, size); System.out.println("\n\n\n\n"); } //------------------------------------ // p.127 public static double findAvg(double[] arr, int size) { double sum = 0; for(int i=0; i