Advertisement
yovkovbpfps

While Loop Graduation

Apr 3rd, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Graduation {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. String student = scanner.nextLine();
  7. double totalGrades = 0;
  8. int classCount = 0;
  9.  
  10. while (classCount < 12){
  11. double grade = Double.parseDouble(scanner.nextLine());
  12.  
  13. if (grade >= 4.00){
  14. classCount++;
  15. totalGrades += grade;
  16. }
  17. }
  18.  
  19. System.out.printf("%s graduated. Average grade: %.2f",student,totalGrades / 12);
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement