Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Graduation {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String name = scanner.nextLine();
- int breakPoint = 0, counter = 1;
- double sumGrades = 0;
- while (true) {
- double grade = Double.parseDouble(scanner.nextLine());
- if (grade >= 4) {
- sumGrades += grade;
- counter++;
- } else {
- breakPoint++;
- }
- if (counter == 13) {
- System.out.printf("%s graduated. Average grade: %.2f\n", name, sumGrades / 12);
- break;
- }
- if (breakPoint == 2) {
- System.out.printf("%s has been excluded at %d grade", name, counter);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement