O'Reilly logo

Java™ How To Program (Early Objects), Tenth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Class StudentTest

To demonstrate the nested if...else statements in class Student’s getLetterGrade method, class StudentTest’s main method (Fig. 4.5) creates two Student objects (lines 7–8). Next, lines 10–13 display each Student’s name and letter grade by calling the objects’ getName and getLetterGrade methods, respectively.

 1   // Fig. 4.5: StudentTest.java 2   // Create and test Student objects. 3   public class StudentTest 4   { 5      public static void main(String[] args) 6      { 7         Student account1 = new Student("Jane Green", 93.5)8         Student account2 = new Student("John Blue", 72.75); 9 10         System.out.printf("%s's letter grade is: %s%n",11            account1.getName(), account1.getLetterGrade() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required