Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package S4_FoorLoops;
- import java.util.Scanner;
- public class Histogram {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int p1 = 0;
- int p2 = 0;
- int p3 = 0;
- int p4 = 0;
- int p5 = 0;
- for (int i = 1; i <= n; i++) {
- int digit = Integer.parseInt(scanner.nextLine());
- if (digit < 200) {
- p1++;
- } else if (digit <= 399) {
- p2++;
- } else if (digit <= 599) {
- p3++;
- } else if (digit <= 799) {
- p4++;
- } else if (digit >= 800) {
- p5++;
- }
- }
- System.out.printf("%.2f%%%n", (1.0 * p1) / n * 100);
- System.out.printf("%.2f%%%n", 1.0*p2/n * 100);
- System.out.printf("%.2f%%%n", 1.0*p3/n * 100);
- System.out.printf("%.2f%%%n", 1.0*p4/n * 100);
- System.out.printf("%.2f%%%n", 1.0*p5/n * 100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement