Advertisement
Lyubohd

04. Fitness Center

Oct 24th, 2020
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.67 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int clients = Integer.parseInt(scan.nextLine());
  7.         //("Back", "Chest", "Legs", "Abs", "Protein shake" или "Protein bar")
  8.         int backCount = 0;
  9.         int chestCount = 0;
  10.         int legsCount = 0;
  11.         int absCount = 0;
  12.         int shakeCount = 0;
  13.         int barCount = 0;
  14.  
  15.         for (int i = 0; i < clients; i++) {
  16.             String input = scan.nextLine();
  17.             if ("Back".equals(input)) {
  18.                 backCount++;
  19.             } else if ("Chest".equals(input)) {
  20.                 chestCount++;
  21.             } else if ("Legs".equals(input)) {
  22.                 legsCount++;
  23.             } else if ("Abs".equals(input)) {
  24.                 absCount++;
  25.             } else if ("Protein shake".equals(input)) {
  26.                 shakeCount++;
  27.             } else if ("Protein bar".equals(input)) {
  28.                 barCount++;
  29.             }
  30.         }
  31.  
  32.         System.out.printf("%d - back%n", backCount);
  33.         System.out.printf("%d - chest%n", chestCount);
  34.         System.out.printf("%d - legs%n", legsCount);
  35.         System.out.printf("%d - abs%n", absCount);
  36.         System.out.printf("%d - protein shake%n", shakeCount);
  37.         System.out.printf("%d - protein bar%n", barCount);
  38.         int workoutPeople = backCount + chestCount + legsCount + absCount;
  39.         int nonWorkoutPeople = shakeCount + barCount;
  40.         System.out.printf("%.2f%% - work out%n", workoutPeople * 1.0 / clients * 100);
  41.         System.out.printf("%.2f%% - protein%n", nonWorkoutPeople * 1.0 / clients * 100);
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement