SHARE
TWEET

Untitled

aggressiveviking Feb 19th, 2020 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class P05_FitnessCenter {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         int visitors = Integer.parseInt(scan.nextLine());
  8.         int back = 0;
  9.         int chest = 0;
  10.         int legs = 0;
  11.         int abs = 0;
  12.         int proteinShake = 0;
  13.         int proteinBar = 0;
  14.         int training = 0;
  15.         int shopping = 0;
  16.  
  17.         for (int i = 0; i < visitors; i++) {
  18.             String activity = scan.nextLine();
  19.             if ("Back".equals(activity)) {
  20.                 back++;
  21.                 training++;
  22.             } else if ("Chest".equals(activity)) {
  23.                 chest++;
  24.                 training++;
  25.             } else if ("Legs".equals(activity)) {
  26.                 legs++;
  27.                 training++;
  28.             } else if ("Abs".equals(activity)) {
  29.                 abs++;
  30.                 training++;
  31.             } else if ("Protein shake".equals(activity)) {
  32.                 proteinShake++;
  33.                 shopping++;
  34.             } else if ("Protein bar".equals(activity)) {
  35.                 proteinBar++;
  36.                 shopping++;
  37.             }
  38.         }
  39.         System.out.println(String.format("%d - back", back));
  40.         System.out.println(String.format("%d - chest", chest));
  41.         System.out.println(String.format("%d - legs", legs));
  42.         System.out.println(String.format("%d - abs", abs));
  43.         System.out.println(String.format("%d - protein shake", proteinShake));
  44.         System.out.println(String.format("%d - protein bar", proteinBar));
  45.         System.out.println(String.format("%.2f%% - work out", (training * 1.0 / (training + shopping)) * 100));
  46.         System.out.println(String.format("%.2f%% - protein", (shopping * 1.0 / (training + shopping)) * 100));
  47.     }
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top