daily pastebin goal
74%
SHARE
TWEET

Untitled

a guest Oct 19th, 2018 66 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. import java.util.Scanner;
  2.  
  3. public class Lab6DivideWithoutRemainder {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.  
  9.         double numbers2 = 0;
  10.         double numbers3 = 0;
  11.         double numbers4 = 0;
  12.  
  13.         for (int i = 0; i < n; i++) {
  14.  
  15.             int number = Integer.parseInt(scanner.nextLine());
  16.  
  17.             if (number % 2 == 0) {
  18.                 numbers2++;
  19.             }
  20.             if (number % 3 == 0) {
  21.                 numbers3++;
  22.             }
  23.             if (number % 4 == 0) {
  24.                 numbers4++;
  25.             }
  26.         }
  27.         System.out.printf("%.2f%n", (numbers2 / n) * 100);
  28.         System.out.printf("%.2f%n", (numbers3 / n) * 100);
  29.         System.out.printf("%.2f%n", (numbers4 / n) * 100);
  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