Advertisement
Stefi16524

Untitled

Dec 30th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package stefi;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Delenie {
  6.  
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9. int count = Integer.parseInt(scanner.nextLine());
  10. double p2 = 0;
  11. double p3 = 0;
  12. double p4 = 0;
  13. for (int i = 0; i < count; i++) {
  14. double number = Double.parseDouble(scanner.nextLine());
  15. if (number % 2 == 0) {
  16. p2++;
  17. }
  18. if (number % 3 == 0) {
  19. p3++;
  20. }
  21. if (number % 4 == 0) {
  22. p4++;
  23. }
  24. }
  25. double percent1 = (p2 / count) * 100;
  26. double percent2 = (p3 / count) * 100;
  27. double percent3 = (p4 / count) * 100;
  28. System.out.printf("%.2f%%%n", percent1);
  29. System.out.printf("%.2f%%%n", percent2);
  30. System.out.printf("%.2f%%%n", percent3);
  31.  
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement