Advertisement
tripTiPscout

08. Graduation

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