Advertisement
SvetlanPetrova

Divide Without Remainder SoftUni

Apr 26th, 2021
820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class DevideWithoutReminder {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scanner = new Scanner(System.in);
  7.         int countNumbers = Integer.parseInt(scanner.nextLine());
  8.  
  9.         double p1Count = 0.0;
  10.         double p2Count = 0.0;
  11.         double p3Count = 0.0;
  12.  
  13.         for (int i = 1; i <= countNumbers; i++) {
  14.             int n = Integer.parseInt(scanner.nextLine());
  15.  
  16.             if (n % 2 == 0) {
  17.                 p1Count ++;
  18.             }
  19.             if (n % 3 == 0) {
  20.                 p2Count ++;
  21.             }
  22.             if (n % 4 == 0) {
  23.                 p3Count ++;
  24.             }
  25.         }
  26.  
  27.         double p1 = p1Count / countNumbers * 100;
  28.         double p2 = p2Count / countNumbers * 100;
  29.         double p3 = p3Count / countNumbers * 100;
  30.  
  31.         System.out.printf("%.2f%%", p1);
  32.         System.out.printf("%n%.2f%%", p2);
  33.         System.out.printf("%n%.2f%%", p3);
  34.  
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement