Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class demo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int stadiumCapacity = Integer.parseInt(scanner.nextLine());
- int fansCount = Integer.parseInt(scanner.nextLine());
- double sectorA = 0;
- double sectorB = 0;
- double sectorV = 0;
- double sectorG = 0;
- for (int i = 0; i < fansCount; i++) {
- char sector = scanner.nextLine().charAt(0);
- if(sector == 'A'){
- sectorA++;
- }else if(sector == 'B'){
- sectorB++;
- }else if(sector == 'V'){
- sectorV++;
- }else if(sector == 'G'){
- sectorG++;
- }
- }
- double sectorAPercentage = sectorA / fansCount * 100;
- double sectorBPercentage = sectorB / fansCount * 100;
- double sectorVPercentage = sectorV / fansCount * 100;
- double sectorGPercentage = sectorG / fansCount * 100;
- double stadiumPercentage = (double)fansCount / stadiumCapacity * 100;
- System.out.printf("%.2f%%%n",sectorAPercentage);
- System.out.printf("%.2f%%%n",sectorBPercentage);
- System.out.printf("%.2f%%%n",sectorVPercentage);
- System.out.printf("%.2f%%%n",sectorGPercentage);
- System.out.printf("%.2f%%%n",stadiumPercentage);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement