Advertisement
CarmenPop

Untitled

Feb 21st, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement