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 input = new Scanner(System.in);
- int n = Integer.parseInt(input.nextLine());
- int p1 = 0;
- int p2 = 0;
- int p3 = 0;
- int counter = 0;
- for (int i = 0; i < n; i++) {
- int currentNumber = Integer.parseInt(input.nextLine());
- counter++;
- if (currentNumber % 2 == 0) {
- p1++;
- }
- if (currentNumber % 3 == 0) {
- p2++;
- }
- if (currentNumber % 4 == 0) {
- p3++;
- }
- }
- System.out.printf("%.2f%%\n", (double) 100 * p1 / counter);
- System.out.printf("%.2f%%\n", (double) 100 * p2 / counter);
- System.out.printf("%.2f%%\n", (double) 100 * p3 / counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment