Advertisement
elvirynwa

Untitled

Nov 4th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class GraduationPart2 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String name = scanner.nextLine();
  8. int educationLevel = 1;
  9. double sumOfGrades = 0;
  10. int poorGrade = 1;
  11.  
  12.  
  13. while (educationLevel <= 12) {
  14. double grade = Double.parseDouble(scanner.nextLine());
  15.  
  16. if (grade < 4) {
  17. poorGrade++;
  18. if (poorGrade >= 2) {
  19. System.out.printf("Mimi has been excluded at %d grade", educationLevel);
  20. return;
  21. }
  22. continue;
  23. }
  24.  
  25. sumOfGrades += grade;
  26. educationLevel++;
  27.  
  28. }
  29.  
  30. System.out.printf("%s graduated. Average grade: %.2f", name, sumOfGrades / 12);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement