Advertisement
Spocoman

07. Trekking Mania

Aug 27th, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 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.         int groupNumbers = Integer.parseInt(scanner.nextLine());
  7.         int musala = 0, montBlanc = 0, kilimanjaro = 0, k2 = 0, everest = 0, alpinistSum = 0;
  8.  
  9.         for (int i = 0; i < groupNumbers; i++) {
  10.             int group = Integer.parseInt(scanner.nextLine());
  11.             alpinistSum += group;
  12.             if (group > 40) {
  13.                 everest += group;
  14.             } else if (group > 25) {
  15.                 k2 += group;
  16.             } else if (group > 12) {
  17.                 kilimanjaro += group;
  18.             } else if (group > 5) {
  19.                 montBlanc += group;
  20.             } else if (group > 0) {
  21.                 musala += group;
  22.             }
  23.         }
  24.  
  25.         System.out.printf("%.2f%%\n", 100.0 * musala / alpinistSum);
  26.         System.out.printf("%.2f%%\n", 100.0 * montBlanc / alpinistSum);
  27.         System.out.printf("%.2f%%\n", 100.0 * kilimanjaro / alpinistSum);
  28.         System.out.printf("%.2f%%\n", 100.0 * k2 / alpinistSum);
  29.         System.out.printf("%.2f%%\n", 100.0 * everest / alpinistSum);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement