Advertisement
Didart

Trekking Mania

Jan 10th, 2022
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.74 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TrekkingMania {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int groups = Integer.parseInt(scanner.nextLine());
  8.  
  9.         double allPeople = 0.00;
  10.         int maxPeopleMusala = 0;
  11.         int maxPeopleMonblan = 0;
  12.         int maxPeopleKilimandzharo = 0;
  13.         int maxPeopleK2 = 0;
  14.         int maxPeopleEverest = 0;
  15.  
  16.         for (int i = 0; i < groups; i++) {
  17.             int peopleInGroup = Integer.parseInt(scanner.nextLine());
  18.             allPeople += peopleInGroup;
  19.             if (peopleInGroup <= 5) {
  20.                 maxPeopleMusala += peopleInGroup;
  21.             } else if (peopleInGroup <= 12) {
  22.                 maxPeopleMonblan += peopleInGroup;
  23.             } else if (peopleInGroup <= 25) {
  24.                 maxPeopleKilimandzharo += peopleInGroup;
  25.             }else if (peopleInGroup <= 40) {
  26.                 maxPeopleK2 += peopleInGroup;
  27.             } else {
  28.                 maxPeopleEverest += peopleInGroup;
  29.             }
  30.         }
  31.  
  32.         double perMusala = (maxPeopleMusala / allPeople) * 100;
  33.         System.out.printf("%.2f%%%n", perMusala);
  34.         double perMonblan = (maxPeopleMonblan / (allPeople)) * 100;
  35.         System.out.printf("%.2f%%%n", perMonblan);
  36.         double perKilimandzharo = (maxPeopleKilimandzharo / allPeople) * 100;
  37.         System.out.printf("%.2f%%%n", perKilimandzharo);
  38.         double perK2 = (maxPeopleK2 / (allPeople)) * 100;
  39.         System.out.printf("%.2f%%%n", perK2);
  40.         double perEverest = (maxPeopleEverest / (allPeople)) * 100;
  41.         System.out.printf("%.2f%%%n", perEverest);
  42.  
  43.  
  44.     }
  45. }
  46.  
  47.  
  48.  /*       int n = Integer.parseInt(scanner.nextLine());
  49.  
  50.         int g1 = 0;
  51.         int g2 = 0;
  52.         int g3 = 0;
  53.         int g4 = 0;
  54.         int g5 = 0;
  55.  
  56.         for (int i = 1; i <= n; i++) {
  57.             int climbersCount = Integer.parseInt(scanner.nextLine());
  58.  
  59.             if (climbersCount < 6) {
  60.                 g1 += climbersCount;
  61.             } else if (climbersCount < 13) {
  62.                 g2 += climbersCount;
  63.             } else if (climbersCount < 26) {
  64.                 g3 += climbersCount;
  65.             } else if (climbersCount < 41) {
  66.                 g4 += climbersCount;
  67.             } else {
  68.                 g5 += climbersCount;
  69.             }
  70.         }
  71.  
  72.         int totalCount = g1 + g2 + g3 + g4 + g5;
  73.  
  74.         System.out.printf("1.0 * g1 / totalCount * 100 %.2f%%", g1);
  75.         System.out.printf("1.0 * g2 / totalCount * 100 %.2f%%", g2);
  76.         System.out.printf("1.0 * g3 / totalCount * 100 %.2f%%", g3);
  77.         System.out.printf("1.0 * g4 / totalCount * 100 %.2f%%", g4);
  78.         System.out.printf("1.0 * g5 / totalCount * 100 %.2f%%", g5);
  79.     }
  80. }
  81.  
  82.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement