0% found this document useful (0 votes)
21 views2 pages

Gradebook Test

This document contains the code for a GradeBookTest.java program that creates and manipulates GradeBook objects. It imports the Scanner utility, declares a main method, creates a GradeBook object and assigns it to a variable, prompts the user to input a course name and sets the course name, displays an initial message, then creates two additional GradeBook objects with preset course names and displays the names. The summary provides the essential information that the program creates and manipulates GradeBook objects by getting user input, setting course names, and displaying messages and names.

Uploaded by

zoolahishkobob
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Gradebook Test

This document contains the code for a GradeBookTest.java program that creates and manipulates GradeBook objects. It imports the Scanner utility, declares a main method, creates a GradeBook object and assigns it to a variable, prompts the user to input a course name and sets the course name, displays an initial message, then creates two additional GradeBook objects with preset course names and displays the names. The summary provides the essential information that the program creates and manipulates GradeBook objects by getting user input, setting course names, and displaying messages and names.

Uploaded by

zoolahishkobob
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

GradeBookTest.

java
1 import java.util.Scanner; // program uses Scanner
2
3 /**
4 * Figs. 3.8 and 3.11: GradeBookTest.java <br>
5 * Creating and manipulating a GradeBook object.
6 *
7 * @author Deitel & Associates, Inc.
8 */
9 public class GradeBookTest {
10
/**
11
* Main method begins program execution.
12
*/
13
public static void main(String[] args) {
14
// Fig 3.8 code
15
16
// create Scanner to obtain input from command window
17
Scanner input = new Scanner(System.in);
18
19
// create a GradeBook object and assign it to myGradeBook
20
GradeBook myGradeBook = new GradeBook();
21
22
// display initial value of courseName
23
System.out.printf( "Initial course name is: %s\n\n",
24
myGradeBook.getCourseName() );
25
26
// prompt for and read course name
27
System.out.println( "Please enter the course name:" );
28
String theName = input.nextLine(); // read a line of text
29
myGradeBook.setCourseName( theName ); // set the course name
30
System.out.println(); // outputs a blank line
31
32
// display welcome message after specifying course name
33
myGradeBook.displayMessage();
34
35
// Fig. 3.11 code
36
37
// create GradeBook object
38
GradeBook gradeBook1 = new GradeBook(
39
"CS101 Introduction to Java Programming" );
40
GradeBook gradeBook2 = new GradeBook(
41
"CS102 Data Structures in Java" );
42
43
// display initial value of courseName for each GradeBook
44
System.out.printf( "gradeBook1 course name is: %s\n",
Page 1

GradeBookTest.java
45
gradeBook1.getCourseName() );
46
System.out.printf( "gradeBook2 course name is: %s\n",
47
gradeBook2.getCourseName() );
48
} // end main method
49 } // end class
50

Page 2

You might also like