Advertisement
Spocoman

Division Without Remainder

Sep 4th, 2024 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int n = Integer.parseInt(scanner.nextLine()),
  7.                 number, p1 = 0, p2 = 0, p3 = 0;
  8.  
  9.         for (int i = 1; i <= n; i++) {
  10.             number = Integer.parseInt(scanner.nextLine());
  11.             if (number % 2 == 0) {
  12.                 p1++;
  13.             }
  14.             if (number % 3 == 0) {
  15.                 p2++;
  16.             }
  17.             if (number % 4 == 0) {
  18.                 p3++;
  19.             }
  20.         }
  21.  
  22.         System.out.printf("%.2f%%\n%.2f%%\n%.2f%%\n", 100.0 * p1 / n, 100.0 * p2 / n, 100.0 * p3 / n);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement