NikolayPresolski

Задача 4.2

Dec 15th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. package Java1program;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Chetiri_Dwe {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int count = Integer.parseInt(scanner.nextLine());
  9.         double p2 = 0;
  10.         double p3 = 0;
  11.         double p4 = 0;
  12.         for (int i = 0; i < count; i++) {
  13.             double number = Double.parseDouble(scanner.nextLine());
  14.             if (number % 2 == 0) {
  15.                 p2++;
  16.             }
  17.             if (number % 3 == 0) {
  18.                 p3++;
  19.             }
  20.             if (number % 4 == 0) {
  21.                 p4++;
  22.             }
  23.         }
  24.         double percent1 = (p2 / count) * 100;
  25.         double percent2 = (p3 / count) * 100;
  26.         double percent3 = (p4 / count) * 100;
  27.         System.out.printf("%.2f%%%n", percent1);
  28.         System.out.printf("%.2f%%%n", percent2);
  29.         System.out.printf("%.2f%%%n", percent3);
  30.     }
  31. }
Add Comment
Please, Sign In to add comment