Advertisement
Vladkoheca

Treking mania.java

Mar 4th, 2024 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.         int n = sc.nextInt(); // Broq na grupite ot katerachi. (n)
  7.         int all = 0; // Vsichki katerachi. (all)
  8.         int[] counts = new int[5];
  9.         for (int i = 0; i < n; i++){
  10.             int gm = sc.nextInt(); // Promenliva za broq na horata v grupata. (gm)
  11.             if (gm<6) counts[0]+=gm;
  12.             else if (gm<13) counts[1]+=gm;
  13.             else if (gm<26) counts[2]+=gm;
  14.             else if (gm<41) counts[3]+=gm;
  15.             else counts[4]+=gm;
  16.             all += gm;
  17.         }
  18.         System.out.format("musala - %10.2f%%%n", counts[0]*100.0/all);
  19.         System.out.format("Monblan - %10.2f%%%n", counts[1]*100.0/all);
  20.         System.out.format("Kilimanjaro - %10.2f%%%n", counts[2]*100.0/all);
  21.         System.out.format("K2 - %10.2f%%%n", counts[3]*100.0/all);
  22.         System.out.format("Everest - %10.2f%%%n", counts[4]*100.0/all);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement