SvetlanPetrova

Graduation Part 2 SoftUni

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