Advertisement
MoPhreak

Untitled

Oct 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class DivideWithoutRemainer {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int n = Integer.parseInt(scanner.nextLine());
  7.         int p2 = 0;
  8.         int p3 = 0;
  9.         int p4 = 0;
  10.         for (int i = 0; i < n; i++) {
  11.             int num = Integer.parseInt(scanner.nextLine());
  12.             if (num % 2 == 0) {
  13.                 p2++;
  14.             }
  15.             if (num % 3 == 0) {
  16.                 p3++;
  17.             }
  18.             if (num % 4 == 0) {
  19.                 p4++;
  20.             }
  21.         }
  22.         double p2res = p2 / (n * 1.0) * 100;
  23.         double p3res = p3 / (n * 1.0) * 100;
  24.         double p4res = p4 / (n * 1.0) * 100;
  25.         System.out.printf("%.2f%%%n", p2res);
  26.         System.out.printf("%.2f%%%n", p3res);
  27.         System.out.printf("%.2f%%%n", p4res);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement