Advertisement
Spocoman

Football League

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