Advertisement
Spocoman

07. Football League

Aug 28th, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FootballLeague {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int stadiumCapacity = Integer.parseInt(scanner.nextLine());
  7.         int footballFans = Integer.parseInt(scanner.nextLine());
  8.         int sectorA = 0, sectorB = 0, sectorV = 0, sectorG = 0;
  9.  
  10.         for (int i = 0; i < footballFans; i++) {
  11.             String sector = scanner.nextLine();
  12.  
  13.             switch (sector) {
  14.                 case "A" -> sectorA++;
  15.                 case "B" -> sectorB++;
  16.                 case "V" -> sectorV++;
  17.                 case "G" -> sectorG++;
  18.             }
  19.         }
  20.  
  21.         System.out.printf("%.2f%%\n", (double) sectorA / footballFans * 100);
  22.         System.out.printf("%.2f%%\n", (double) sectorB / footballFans * 100);
  23.         System.out.printf("%.2f%%\n", (double) sectorV / footballFans * 100);
  24.         System.out.printf("%.2f%%\n", (double) sectorG / footballFans * 100);
  25.         System.out.printf("%.2f%%\n", (double) footballFans / stadiumCapacity * 100);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement