Chapter 4 Control Structures: Part (Web site domain) 1 163 Fig.
Chapter 4 Control Structures: Part 1 163 Fig. 4.7Class-average program with counter-controlled repetition (part 3 of 3). Fig. 4. Good Programming Practice 4.6 Initialize counters and totals. Line 5, import javax.swing.JOptionPane; imports class JOptionPane to enable the program to read data from the keyboard and output data to the screen using the input dialog and message dialog shown in Chapter 2. Line 7 begins the definition of application class Average1. Remember that the definition of an application class must contain a main method (lines 10 49) in order for the application to be executed. Lines 12 16, int total, // sum of grades gradeCounter, // number of grades entered gradeValue, // grade value average; // average of all grades String grade; // grade typed by user declare variables total, gradeCounter, gradeValue and average to be of type intand variable gradeto be of type String. Variable gradestores the Stringthe Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01