Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Grades {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int students = Integer.parseInt(scanner.nextLine());
- double grade3 = 0, grade4 = 0, grade5 = 0, grade6 = 0, gradeSum = 0;
- for (int i = 0; i < students; i++) {
- double grade = Double.parseDouble(scanner.nextLine());
- if (grade >= 5) {
- grade6++;
- } else if (grade >= 4) {
- grade5++;
- } else if (grade >= 3) {
- grade4++;
- } else if (grade >= 2) {
- grade3++;
- }
- gradeSum += grade;
- }
- System.out.printf("Top students: %.2f%%\n", grade6 / students * 100);
- System.out.printf("Between 4.00 and 4.99: %.2f%%\n", grade5 / students * 100);
- System.out.printf("Between 3.00 and 3.99: %.2f%%\n", grade4 / students * 100);
- System.out.printf("Fail: %.2f%%\n", grade3 / students * 100);
- System.out.printf("Average: %.2f\n", gradeSum / students);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement