Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FootballLeague {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int kapacitet = Integer.parseInt(scanner.nextLine());
- int fans = Integer.parseInt(scanner.nextLine());
- double sektorA = 0;
- double sektorB = 0;
- double sektorV = 0;
- double sektorG = 0;
- for (int i = 1; i <= fans; i++) {
- String sektor = scanner.nextLine();
- if (sektor.equals("A")) {
- sektorA++;
- }
- if (sektor.equals("B")) {
- sektorB++;
- }
- if (sektor.equals("V")) {
- sektorV++;
- }
- if (sektor.equals("G")) {
- sektorG++;
- }
- }
- double perA = (sektorA / fans) * 100;
- double perB = (sektorB / fans) * 100;
- double perV = (sektorV / fans) * 100;
- double perG = (sektorG / fans) * 100;
- double perAll = (((double) fans) / ((double) kapacitet)) * 100;
- System.out.printf("%.2f%%%n %.2f%%%n %.2f%%%n %.2f%%%n %.2f%%%n", perA, perB, perV, perG, perAll);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement