Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class demo {
- 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 = 0; i < n; i++) {
- int currentNum = Integer.parseInt(scanner.nextLine());
- if(currentNum < 200){
- p1++;
- }else if(currentNum >= 200 && currentNum <= 399){
- p2++;
- }else if(currentNum >= 400 && currentNum <= 599){
- p3++;
- }else if(currentNum >= 600 && currentNum <= 799){
- p4++;
- }else if(currentNum >= 800){
- p5++;
- }
- }
- System.out.printf("%.2f%%\n",(double) p1 / n * 100);
- System.out.printf("%.2f%%\n",(double) p2 / n * 100);
- System.out.printf("%.2f%%\n",(double) p3 / n * 100);
- System.out.printf("%.2f%%\n",(double) p4 / n * 100);
- System.out.printf("%.2f%%\n",(double) p5 / n * 100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement