Samuella

Graduation

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