Advertisement
psi_mmobile

Untitled

May 14th, 2022
830
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         int studentCount = scanner.nextInt();
  5.         double examMark = 0;
  6.         int topStudents = 0;
  7.         int students4and5 = 0;
  8.         int students3and4 = 0;
  9.         int failedStudents = 0;
  10.         double allMarksSum = 0.0;
  11.         for (int i = 1; i <= studentCount; i++) {
  12.             examMark = scanner.nextDouble();
  13.             if (examMark >= 5.00) {
  14.                 topStudents++;
  15.             }
  16.             if (examMark >= 4.00 && examMark <= 4.99) {
  17.                 students4and5++;
  18.             }
  19.             if (examMark >= 3.00 && examMark <= 3.99) {
  20.                 students3and4++;
  21.             }
  22.             if (examMark < 3.00) {
  23.                 failedStudents++;
  24.             }
  25.             allMarksSum += examMark;
  26.         }
  27.         System.out.printf("Top students: %.2f%%\n",(double)topStudents/studentCount * 100);
  28.         System.out.printf("Between 4.00 and 4.99: %.2f%%\n",(double)students4and5/studentCount * 100);
  29.         System.out.printf("Between 3.00 and 3.99: %.2f%%\n",(double)students3and4/studentCount * 100);
  30.         System.out.printf("Fail: %.2f%%\n",(double)failedStudents/studentCount * 100);
  31.         System.out.printf("Average: %.2f",(double)allMarksSum/studentCount);
  32.     }
  33. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement