Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DivideWithoutRemainer {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int p2 = 0;
- int p3 = 0;
- int p4 = 0;
- for (int i = 0; i < n; i++) {
- int num = Integer.parseInt(scanner.nextLine());
- if (num % 2 == 0) {
- p2++;
- }
- if (num % 3 == 0) {
- p3++;
- }
- if (num % 4 == 0) {
- p4++;
- }
- }
- double p2res = p2 / (n * 1.0) * 100;
- double p3res = p3 / (n * 1.0) * 100;
- double p4res = p4 / (n * 1.0) * 100;
- System.out.printf("%.2f%%%n", p2res);
- System.out.printf("%.2f%%%n", p3res);
- System.out.printf("%.2f%%%n", p4res);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement