SHARE
TWEET

Graduation /// While

valentin955 Apr 19th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class Hi {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.        String name = scanner.nextLine();
  10.  
  11.        int counter = 1;
  12.  
  13.        double gradeSum = 0;
  14.  
  15.        while (counter <= 12){
  16.            double grade = Double.parseDouble(scanner.nextLine());
  17.  
  18.            if (grade >= 4){
  19.                gradeSum += grade;
  20.                counter++;
  21.            }
  22.        }
  23.         System.out.printf("%s graduated. Average grade: %.2f",name, gradeSum / 12);
  24.     }
  25.  
  26. }
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