Advertisement
desislava_topuzakova

04. Trekking Mania

Mar 31st, 2020
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TrekkingMania_04 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int groups = Integer.parseInt(scanner.nextLine());
  8.  
  9.         int countMusala = 0;
  10.         int countMonblan = 0;
  11.         int countKili = 0;
  12.         int countK2 = 0;
  13.         int countEverest = 0;
  14.         int countPeople = 0;
  15.  
  16.         for (int group = 1; group <= groups ; group++) {
  17.             int people = Integer.parseInt(scanner.nextLine());
  18.             countPeople += people;
  19.  
  20.             if (people <= 5) {
  21.                 countMusala += people;
  22.             } else if (people <= 12) {
  23.                 countMonblan += people;
  24.             } else if (people <= 25) {
  25.                 countKili += people;
  26.             } else if (people <= 40) {
  27.                 countK2 += people;
  28.             } else {
  29.                 countEverest += people;
  30.             }
  31.         }
  32.  
  33.         double percentMusala = countMusala * 1.0 / countPeople * 100;
  34.         double percentMonblan = countMonblan * 1.0 / countPeople * 100;
  35.         double percentKili = countKili * 1.0 / countPeople * 100;
  36.         double percentK2= countK2 * 1.0 / countPeople * 100;
  37.         double percentEverest= countEverest * 1.0 / countPeople * 100;
  38.  
  39.         System.out.printf("%.2f%%%n", percentMusala);
  40.         System.out.printf("%.2f%%%n", percentMonblan);
  41.         System.out.printf("%.2f%%%n", percentKili);
  42.         System.out.printf("%.2f%%%n", percentK2);
  43.         System.out.printf("%.2f%%%n", percentEverest);
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement