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