Preview:
// Get student names
do {
   newStudent = input.nextLine();

   if (!newStudent.equals("")) {
      students.add(newStudent);
   }

} while(!newStudent.equals(""));


// for -each Get student grades
for (String student : students) {
   System.out.print("Grade for " + student + ": ");
   Double grade = input.nextDouble();
   grades.add(grade);
}
// Print class roster
System.out.println("\nClass roster:");
double sum = 0.0;

for (int i = 0; i < students.size(); i++) {
   System.out.println(students.get(i) + " (" + grades.get(i) + ")");
   sum += grades.get(i);
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter