Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Demo {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String studentName = scan.nextLine();
- double grades = 0;
- int counter = 0;
- // 0 1 2 3 4 5 6 7 8 9 10 11 -> 12
- // 1 2 3 4 5 6 7 8 9 10 11 12 -> 12
- while (counter < 12) {
- double grade = Double.parseDouble(scan.nextLine());
- if (grade >= 4.0) {
- grades += grade;
- counter++;
- }
- }
- double avgGrade = grades / 12;
- System.out.printf("%s graduated. Average grade: %.2f", studentName, avgGrade);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement