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() ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.