SHARE
TWEET

Задача 4.2

NikolayPresolski Dec 13th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top