EliPerfanova

Graduation pt.2

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