Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SoftUniCamp {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- double group1 = 0;
- double group2 = 0;
- double group3 = 0;
- double group4 = 0;
- double group5 = 0;
- double total = 0;
- for (int i = 0; i <n; i++) {
- int num = Integer.parseInt(scanner.nextLine());
- if (num<=5){
- group1 += num;
- } else if ((num>=6) && (num<=12)){
- group2 += num;
- } else if ((num>=13) && (num<=25)){
- group3 += num;
- } else if ((num>=26) && (num<=40)){
- group4 += num;
- } else if (num>=41){
- group5 += num;
- }
- }
- total = group1 + group2 + group3 + group4 + group5;
- System.out.printf("%.2f%%%n", (group1/total)*100);
- System.out.printf("%.2f%%%n", (group2/total)*100);
- System.out.printf("%.2f%%%n", (group3/total)*100);
- System.out.printf("%.2f%%%n", (group4/total)*100);
- System.out.printf("%.2f%%", (group5/total)*100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement