Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Exam_06_March_2016 - created by borkins on 2017-05-14.
- */
- import java.util.Scanner;
- public class _04_Histogram
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int n = Integer.parseInt(console.nextLine());
- int[] p = new int[5];
- for (int i = 0; i < n; i++)
- {
- int num = Integer.parseInt(console.nextLine());
- if (num < 200) p[0]++;
- else if (num < 400) p[1]++;
- else if (num < 600) p[2]++;
- else if (num < 800) p[3]++;
- else p[4]++;
- }
- for (int i = 0; i < p.length; i++)
- {
- System.out.printf("%.2f%%%n", (p[i] / (double) n * 100));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment