//----------------------------------------------------------------------------- // Grades Example //----------------------------------------------------------------------------- import java.text.DecimalFormat; public class grades { public static void main(String[] args) { //--------------------------------------------------------------------- // Setup for user input //--------------------------------------------------------------------- TokenReader in = new TokenReader(System.in); //--------------------------------------------------------------------- // Declare and initialize variables to store information //--------------------------------------------------------------------- int count; double max, min, sum, grade, average; // We need a grade to start the analysis System.out.print("Enter a grade: "); ___________________________________ ; count = ____ ; // count of grades so far max = ______ ; // max grade so far -- use initial grade min = ______ ; // min grade so far -- use initial grade sum = ______ ; // sum of grades so far average = __ ; // average of grades so far //--------------------------------------------------------------------- // Loop for processing input and computing desired values // Stop loop when user enters a negative value //--------------------------------------------------------------------- while(___________________) { //*************************** // REPETITION // Echo current grade //*************************** //**************************** // ACCUMULATION // Count the grades so far // Sum the grades so far //**************************** //**************************** // CONDITIONAL UPDATE // Determine min/max of grades //**************************** //**************************** // Input the next grade //**************************** } //--------------------------------------------------------------------- // Output results // Format to two decimal places //--------------------------------------------------------------------- DecimalFormat fmt = new DecimalFormat("0.##"); if(______________________________________) System.out.println("\nNo values entered"); else { System.out.println(); System.out.println("Number of grades: " + count); System.out.println("Average of grades: " + fmt.format(sum/count)); System.out.println("Maximum grade: " + max); System.out.println("Minimum grade: " + min); } } // method main } // class grades