Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String name = scanner.nextLine();
- int actualclass = 0;
- int countclass = 0;
- double total = 0;
- while(true){
- double grade = scanner.nextDouble();
- total += grade;
- countclass++;
- if(grade >= 4){
- actualclass++;
- }else{
- countclass++;
- }
- if(actualclass == 12){
- System.out.printf("%s graduated. Average grade: %.2f", name, total / countclass);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement