Advertisement
Dido09

DeleneBezOstatuk

Oct 16th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class DivideWithiot {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int NumberOfLoops = Integer.parseInt(scanner.nextLine());
  8.  
  9. double Divide2 = 0.0;
  10. double Divide3 = 0.0;
  11. double Divide4 = 0.0;
  12.  
  13. for (int Index = 0; Index < NumberOfLoops; Index++)
  14. {
  15. int Number = Integer.parseInt(scanner.nextLine());
  16.  
  17. if (Number % 2 == 0)
  18. {
  19. Divide2++;
  20. }
  21. if (Number % 3 == 0)
  22. {
  23. Divide3++;
  24. }
  25. if (Number % 4 == 0)
  26. {
  27. Divide4++;
  28. }
  29. }
  30.  
  31. double PercentOf2 = (Divide2 * 100) / NumberOfLoops;
  32. double PercentOf3 = (Divide3 * 100) / NumberOfLoops;
  33. double PercentOf4 = (Divide4 * 100) / NumberOfLoops;
  34.  
  35.  
  36. System.out.printf("%.2f%%%n", PercentOf2);
  37.  
  38. System.out.printf("%.2f%%%n", PercentOf3);
  39.  
  40. System.out.printf("%.2f%%%n", PercentOf4);
  41.  
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement