Advertisement
Ivakis

Деление без остатък

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