Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package _04_ForLoops;
- import java.util.Scanner;
- public class TrekkingMania {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int groupsCount = Integer.parseInt(scanner.nextLine());
- int allPeople = 0;
- int musalaPeople = 0;
- int monblancPeople = 0;
- int kilimandjaroPeople = 0;
- int k2People = 0;
- int everestPeople = 0;
- for (int i = 1; i <= groupsCount; i++) {
- int people = Integer.parseInt(scanner.nextLine());
- allPeople += people;
- if(people <= 5) {
- musalaPeople += people;
- } else if (people <= 12) {
- monblancPeople += people;
- } else if (people <= 25) {
- kilimandjaroPeople += people;
- } else if (people <= 40) {
- k2People += people;
- } else if (people >= 41) {
- everestPeople += people;
- }
- }
- System.out.printf("%.2f%%%n", (1.0 * musalaPeople) / allPeople * 100);
- System.out.printf("%.2f%%%n", (1.0 * monblancPeople) / allPeople * 100);
- System.out.printf("%.2f%%%n", (1.0 * kilimandjaroPeople) / allPeople * 100);
- System.out.printf("%.2f%%%n", (1.0 * k2People) / allPeople * 100);
- System.out.printf("%.2f%%%n", (1.0 * everestPeople) / allPeople * 100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement