Advertisement
psi_mmobile

Untitled

May 15th, 2022
812
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1.  //7.   Футболен турнир
  2. public class MyClass {
  3.     public static void main(String args[]) {
  4.        java.util.Scanner scanner = new java.util.Scanner(System.in);
  5.        int stadiumCapacity = scanner.nextInt();
  6.        int fans = scanner.nextInt();
  7.        String sector = null;
  8.        
  9.        int fansInASector = 0;
  10.        int fansInBSector = 0;
  11.        int fansInVSector = 0;
  12.        int fansInGSector = 0;
  13.        
  14.        for (int i = 1; i <= fans; i++) {
  15.            sector = scanner.next();
  16.            switch (sector) {
  17.                case "A" : fansInASector++; break;
  18.                case "B" : fansInBSector++; break;
  19.                case "V" : fansInVSector++; break;
  20.                case "G" : fansInGSector++; break;
  21.            }
  22.        }
  23.        System.out.printf("%.2f%%\n", (double)fansInASector / fans * 100);
  24.        System.out.printf("%.2f%%\n", (double)fansInBSector / fans * 100);
  25.        System.out.printf("%.2f%%\n", (double)fansInVSector / fans * 100);
  26.        System.out.printf("%.2f%%\n", (double)fansInGSector / fans * 100);
  27.        System.out.printf("%.2f%%", (double)fans / stadiumCapacity * 100);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement