Advertisement
Deiancom

Football league

Feb 8th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 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 allFans = Integer.parseInt(scanner.nextLine());
  8.         double aSector = 0;
  9.         double bSector = 0;
  10.         double vSector = 0;
  11.         double gSector = 0;
  12.         double allFansPercent = allFans / (double)stadiumCapacity * 100;
  13.         for (int i = 1; i <= allFans ; i++) {
  14.             String sector = scanner.nextLine();
  15.             if (sector.equals("A")) {
  16.                 aSector++;
  17.             }else if (sector.equals("B")) {
  18.                 bSector++;
  19.             }else if (sector.equals("V")) {
  20.                 vSector++;
  21.             }else {
  22.                 gSector++;
  23.             }
  24.         }
  25.         double aPercent = aSector / allFans * 100;
  26.         double bPercent = bSector / allFans * 100;
  27.         double vPercent = vSector / allFans * 100;
  28.         double gPercent = gSector / allFans * 100;
  29.         System.out.printf("%.2f%%%n",aPercent);
  30.         System.out.printf("%.2f%%%n",bPercent);
  31.         System.out.printf("%.2f%%%n",vPercent);
  32.         System.out.printf("%.2f%%%n",gPercent);
  33.         System.out.printf("%.2f%%",allFansPercent);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement