rossirm

04.External Evaluation - Задача 4. Външно оценяване

Nov 6th, 2017
293
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class p04 {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scan = new Scanner(System.in);
  7.  
  8.         double n = Integer.parseInt(scan.nextLine());
  9.  
  10.         int counter1 = 0;
  11.         int counter2 = 0;
  12.         int counter3 = 0;
  13.         int counter4 = 0;
  14.         int counter5 = 0;
  15.  
  16.         for (int i = 1; i <= n; i++) {
  17.             double mark = Double.parseDouble(scan.nextLine());
  18.             if (mark >= 0 && mark < 22.5) {
  19.                 counter1++;
  20.             } else if (mark >= 22.5 && mark < 40.5) {
  21.                 counter2++;
  22.             } else if (mark >= 40.5 && mark < 58.5) {
  23.                 counter3++;
  24.             } else if (mark >= 58.5 && mark < 76.5) {
  25.                 counter4++;
  26.             } else if (mark >= 76.5 && mark <= 100) {
  27.                 counter5++;
  28.             }
  29.         }
  30.         double result1 = counter1 / n * 100.0;
  31.         double result2 = counter2 / n * 100.0;
  32.         double result3 = counter3 / n * 100.0;
  33.         double result4 = counter4 / n * 100.0;
  34.         double result5 = counter5 / n * 100.0;
  35.  
  36.         System.out.printf("%.2f%% poor marks%n", result1);
  37.         System.out.printf("%.2f%% satisfactory marks%n", result2);
  38.         System.out.printf("%.2f%% good marks%n", result3);
  39.         System.out.printf("%.2f%% very good marks%n", result4);
  40.         System.out.printf("%.2f%% excellent marks%n", result5);
  41.     }
  42. }
RAW Paste Data