Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.PrintStream;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int visitors = Integer.parseInt(scanner.nextLine()),
- back = 0,
- chest = 0,
- legs = 0,
- abs = 0,
- proteinBar = 0,
- proteinShake = 0;
- String action;
- for (int i = 0; i < visitors; i++) {
- action = scanner.nextLine();
- switch (action) {
- case "Back" -> back++;
- case "Chest" -> chest++;
- case "Legs" -> legs++;
- case "Abs" -> abs++;
- case "Protein bar" -> proteinBar++;
- default -> proteinShake++;
- }
- }
- System.out.printf(
- """
- %d - back
- %d - chest
- %d - legs
- %d - abs
- %d - protein shake
- %d - protein bar
- %.2f%% - work out
- %.2f%% - protein
- """
- , back, chest, legs, abs, proteinShake, proteinBar,
- 100.0 * (back + chest + legs + abs) / visitors,
- 100.0 * (proteinShake + proteinBar) / visitors
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement