Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class JavaBasics {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int groups = Integer.parseInt(scan.nextLine());
- int musala = 0;
- int monblan = 0;
- int kilimandjaro = 0;
- int k2 = 0;
- int everest = 0;
- double total = 0;
- for (int i = 0; i < groups; i++) {
- int people = Integer.parseInt(scan.nextLine());
- if (people <= 5) {
- musala += people;
- } else if (people <= 16) {
- monblan += people;
- } else if (people <= 25) {
- kilimandjaro += people;
- } else if (people <= 40) {
- k2 += people;
- } else {
- everest += people;
- }
- total+=people;
- }
- System.out.printf("%.2f%%%n",(musala/total)*100);
- System.out.printf("%.2f%%%n",(monblan/total)*100);
- System.out.printf("%.2f%%%n",(kilimandjaro/total)*100);
- System.out.printf("%.2f%%%n",(k2/total)*100);
- System.out.printf("%.2f%%%n",(everest/total)*100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement