Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int games = Integer.parseInt(scanner.nextLine()),
- hearthstones = 0, fornites = 0, overwatches = 0, others = 0;
- String game;
- for (int i = 0; i < games; i++) {
- game = scanner.nextLine();
- switch (game) {
- case "Hearthstone" -> hearthstones++;
- case "Fornite" -> fornites++;
- case "Overwatch" -> overwatches++;
- default -> others++;
- }
- }
- System.out.printf("Hearthstone - %.2f%%\n", 100.0 * hearthstones / games);
- System.out.printf("Fornite - %.2f%%\n", 100.0 * fornites / games);
- System.out.printf("Overwatch - %.2f%%\n", 100.0 * overwatches / games);
- System.out.printf("Others - %.2f%%\n", 100.0 * others / games);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement