SHARE
TWEET

Untitled

CarmenPop Feb 21st, 2020 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static void main(String[] args) {
  2.         Scanner scanner = new Scanner(System.in);
  3.         String name = scanner.nextLine();
  4.         int actualclass = 0;
  5.         int countclass = 0;
  6.         double total = 0;
  7.         while(true){
  8.             double grade = scanner.nextDouble();
  9.             total += grade;
  10.             countclass++;
  11.             if(grade >= 4){
  12.                 actualclass++;
  13.             }else{
  14.                 countclass++;
  15.             }
  16.             if(actualclass == 12){
  17.                 System.out.printf("%s graduated. Average grade: %.2f", name, total / countclass);
  18.                 break;
  19.             }
  20.         }
  21.     }
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