Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Dcoder{
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int capacity = Integer.parseInt(sc.nextLine());
- double fans = Double.parseDouble(sc.nextLine());
- double fansA = 0.0;
- double fansB = 0.0;
- double fansV = 0.0;
- double fansG = 0.0;
- for (int i = 1; i <= fans; i++){
- String sector = sc.nextLine();
- if (sector.equals("A")){
- fansA++;
- }
- if (sector.equals("B")){
- fansB++;
- }
- if (sector.equals("V")){
- fansV++;
- }
- if (sector.equals("G")){
- fansG++;
- }
- }
- System.out.printf("%.2f%%",fansA/fans*100);
- System.out.println();
- System.out.printf("%.2f%%",fansB/fans*100);
- System.out.println();
- System.out.printf("%.2f%%",fansV/fans*100);
- System.out.println();
- System.out.printf("%.2f%%",fansG/fans*100);
- System.out.println();
- System.out.printf("%.2f%%",fans/capacity*100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment