Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class DivideWithOutRemainder {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int n = Integer.parseInt(scanner.nextLine());
  7. int counterP1 = 0;
  8. int counterP2 = 0;
  9. int counterP3 = 0;
  10. for (int i = 1; i <= n; i++) {
  11. int num = Integer.parseInt(scanner.nextLine());
  12. if (num % 2 == 0) {
  13. counterP1++;
  14. }
  15. if (num % 3 == 0) {
  16. counterP2++;
  17. }
  18. if (num % 4 == 0) {
  19. counterP3++;
  20. }
  21. }
  22. double procentP1 = counterP1 * n;
  23. double procentP2 = counterP2 * n;
  24. double procentP3 = counterP3 * n;
  25. System.out.printf("%.2f%n", procentP1);
  26. System.out.printf("%.2f%n", procentP2);
  27. System.out.printf("%.2f", procentP3);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement