SHARE
TWEET

Untitled

elvirynwa Nov 4th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top