Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- int numberCount = scanner.nextInt();
- int p1 = 0;
- int p2 = 0;
- int p3 = 0;
- int p4 = 0;
- int p5 = 0;
- int nextNumber = 0;
- for (int i = 0; i < numberCount; i++) {
- nextNumber = scanner.nextInt();
- if (nextNumber < 200) {
- p1++;
- }
- if (nextNumber >= 200 && nextNumber < 400) {
- p2++;
- }
- if (nextNumber >= 400 && nextNumber < 600) {
- p3++;
- }
- if (nextNumber >= 600 && nextNumber < 800) {
- p4++;
- }
- if (nextNumber >= 800) {
- p5++;
- }
- }
- double p1Part = (double) p1/numberCount;
- double p2Part = (double) p2/numberCount;
- double p3Part = (double) p3/numberCount;
- double p4Part = (double) p4/numberCount;
- double p5Part = (double) p5/numberCount;
- System.out.printf("%.2f%% \n", p1Part * 100);
- System.out.printf("%.2f%% \n", p2Part * 100);
- System.out.printf("%.2f%% \n", p3Part * 100);
- System.out.printf("%.2f%% \n", p4Part * 100);
- System.out.printf("%.2f%% \n", p5Part * 100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement