// Project: ComputeAverage // Module: ave2 // Source code file: Average.java // Enter count of quiz scores. Then enter quiz scores as // double values at the keyboard. Output average of scores. import java.lang.*; import java.util.Scanner; public class Average { public static void main(String[ ] args) { Scanner s = new Scanner(System.in); double sum = 0.0; int n = 1; System.out.print("Enter number of quiz scores: "); int count = Integer.parseInt(s.nextLine( )); while (n <= count) { System.out.print("Quiz score " + n + ":"); double score = Double.parseDouble(s.nextLine( )); sum += score; n++; } if (count > 0) { System.out.println("Average: " + sum / count); } else { System.out.println("No scores were input."); } } }