Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1.  
  2.     // read and save the records
  3.     while (true)
  4.     {
  5.       // ask for records
  6.       System.out.print("How many records? ");
  7.       nStudents = new Double(cin.readLine()).intValue();
  8.       Student aStudent = new Student();
  9.       for (int i = 0; i < nStudents; i++)
  10.       {
  11.         System.out.print("Name: ");
  12.         aStudent.name = cin.readLine();
  13.         System.out.print("ID: ");
  14.         aStudent.id = new Double(cin.readLine()).intValue();
  15.         System.out.print("GPA: ");
  16.         aStudent.gpa = new Double(cin.readLine()).floatValue();    
  17.  
  18.         // add record to list, if it's not full
  19.         if (nStudents < student.length)
  20.           student[nStudents++] = aStudent;
  21.       }  
  22.       break;
  23.     } // while
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement