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