Advertisement
RGeorgiev97

Trekking mania

Apr 30th, 2020
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class JavaBasics {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int groups = Integer.parseInt(scan.nextLine());
  7.         int musala = 0;
  8.         int monblan = 0;
  9.         int kilimandjaro = 0;
  10.         int k2 = 0;
  11.         int everest = 0;
  12.         double total = 0;
  13.         for (int i = 0; i < groups; i++) {
  14.             int people = Integer.parseInt(scan.nextLine());
  15.             if (people <= 5) {
  16.                 musala += people;
  17.             } else if (people <= 16) {
  18.                 monblan += people;
  19.             } else if (people <= 25) {
  20.                 kilimandjaro += people;
  21.             } else if (people <= 40) {
  22.                 k2 += people;
  23.             } else {
  24.                 everest += people;
  25.             }
  26.             total+=people;
  27.         }
  28.         System.out.printf("%.2f%%%n",(musala/total)*100);
  29.         System.out.printf("%.2f%%%n",(monblan/total)*100);
  30.         System.out.printf("%.2f%%%n",(kilimandjaro/total)*100);
  31.         System.out.printf("%.2f%%%n",(k2/total)*100);
  32.         System.out.printf("%.2f%%%n",(everest/total)*100);
  33.  
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement