// The do - while loop example: find the avarage and the highest // grades given a series of scores import java.util.Scanner; class LoopExample3A { public static void main (String[] args) { Scanner scan = new Scanner(System.in); int grade, sum = 0, number = 0; int max = -1; do { System.out.print ("Enter grade (-1, if done): "); System.out.flush (); grade = scan.nextInt(); if (grade != -1) { number = number + 1; if (max < grade) max = grade; sum = sum + grade; } } while (grade != -1); if (number == 0) System.out.println ("No grades enterred."); else { System.out.println ("The avarage grade is " + (sum / number)); System.out.println ("The highest grade is " + max); } } }