Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TrekkingMania {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int groups = Integer.parseInt(scanner.nextLine());
- double allPeople = 0.00;
- int maxPeopleMusala = 0;
- int maxPeopleMonblan = 0;
- int maxPeopleKilimandzharo = 0;
- int maxPeopleK2 = 0;
- int maxPeopleEverest = 0;
- for (int i = 0; i < groups; i++) {
- int peopleInGroup = Integer.parseInt(scanner.nextLine());
- allPeople += peopleInGroup;
- if (peopleInGroup <= 5) {
- maxPeopleMusala += peopleInGroup;
- } else if (peopleInGroup <= 12) {
- maxPeopleMonblan += peopleInGroup;
- } else if (peopleInGroup <= 25) {
- maxPeopleKilimandzharo += peopleInGroup;
- }else if (peopleInGroup <= 40) {
- maxPeopleK2 += peopleInGroup;
- } else {
- maxPeopleEverest += peopleInGroup;
- }
- }
- double perMusala = (maxPeopleMusala / allPeople) * 100;
- System.out.printf("%.2f%%%n", perMusala);
- double perMonblan = (maxPeopleMonblan / (allPeople)) * 100;
- System.out.printf("%.2f%%%n", perMonblan);
- double perKilimandzharo = (maxPeopleKilimandzharo / allPeople) * 100;
- System.out.printf("%.2f%%%n", perKilimandzharo);
- double perK2 = (maxPeopleK2 / (allPeople)) * 100;
- System.out.printf("%.2f%%%n", perK2);
- double perEverest = (maxPeopleEverest / (allPeople)) * 100;
- System.out.printf("%.2f%%%n", perEverest);
- }
- }
- /* int n = Integer.parseInt(scanner.nextLine());
- int g1 = 0;
- int g2 = 0;
- int g3 = 0;
- int g4 = 0;
- int g5 = 0;
- for (int i = 1; i <= n; i++) {
- int climbersCount = Integer.parseInt(scanner.nextLine());
- if (climbersCount < 6) {
- g1 += climbersCount;
- } else if (climbersCount < 13) {
- g2 += climbersCount;
- } else if (climbersCount < 26) {
- g3 += climbersCount;
- } else if (climbersCount < 41) {
- g4 += climbersCount;
- } else {
- g5 += climbersCount;
- }
- }
- int totalCount = g1 + g2 + g3 + g4 + g5;
- System.out.printf("1.0 * g1 / totalCount * 100 %.2f%%", g1);
- System.out.printf("1.0 * g2 / totalCount * 100 %.2f%%", g2);
- System.out.printf("1.0 * g3 / totalCount * 100 %.2f%%", g3);
- System.out.printf("1.0 * g4 / totalCount * 100 %.2f%%", g4);
- System.out.printf("1.0 * g5 / totalCount * 100 %.2f%%", g5);
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement