Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //7. Футболен турнир
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- int stadiumCapacity = scanner.nextInt();
- int fans = scanner.nextInt();
- String sector = null;
- int fansInASector = 0;
- int fansInBSector = 0;
- int fansInVSector = 0;
- int fansInGSector = 0;
- for (int i = 1; i <= fans; i++) {
- sector = scanner.next();
- switch (sector) {
- case "A" : fansInASector++; break;
- case "B" : fansInBSector++; break;
- case "V" : fansInVSector++; break;
- case "G" : fansInGSector++; break;
- }
- }
- System.out.printf("%.2f%%\n", (double)fansInASector / fans * 100);
- System.out.printf("%.2f%%\n", (double)fansInBSector / fans * 100);
- System.out.printf("%.2f%%\n", (double)fansInVSector / fans * 100);
- System.out.printf("%.2f%%\n", (double)fansInGSector / fans * 100);
- System.out.printf("%.2f%%", (double)fans / stadiumCapacity * 100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement