borkins

Exam 26-Mar-2016 - 04. Division Without Remainder

May 14th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. /**
  2.  * Project: Exam_26_March_2016 - created by borkins on 2017-05-14.
  3.  */
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class _04_DivisionWithoutRemainder
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner console = new Scanner(System.in);
  12.    
  13.         int n = Integer.parseInt(console.nextLine());
  14.    
  15.         int[] p = new int[3];
  16.    
  17.         for (int i = 0; i < n; i++)
  18.         {
  19.             int num = Integer.parseInt(console.nextLine());
  20.        
  21.             if (num % 2 == 0) p[0]++;
  22.             if (num % 3 == 0) p[1]++;
  23.             if (num % 4 == 0) p[2]++;
  24.         }
  25.    
  26.         for (int i = 0; i < p.length; i++)
  27.         {
  28.             System.out.printf("%.2f%%%n", (p[i] / (double) n * 100));
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment