Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FootballLeague {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int stadiumCapacity = Integer.parseInt(scanner.nextLine());
- int footballFans = Integer.parseInt(scanner.nextLine());
- int sectorA = 0, sectorB = 0, sectorV = 0, sectorG = 0;
- for (int i = 0; i < footballFans; i++) {
- String sector = scanner.nextLine();
- switch (sector) {
- case "A" -> sectorA++;
- case "B" -> sectorB++;
- case "V" -> sectorV++;
- case "G" -> sectorG++;
- }
- }
- System.out.printf("%.2f%%\n", (double) sectorA / footballFans * 100);
- System.out.printf("%.2f%%\n", (double) sectorB / footballFans * 100);
- System.out.printf("%.2f%%\n", (double) sectorV / footballFans * 100);
- System.out.printf("%.2f%%\n", (double) sectorG / footballFans * 100);
- System.out.printf("%.2f%%\n", (double) footballFans / stadiumCapacity * 100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement