Advertisement
damesova

Divide Without Remainder [Mimi][PB]

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