Advertisement
svephoto

Fitness Center [C#]

Nov 28th, 2019
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.91 KB | None | 0 0
  1. using System;
  2.  
  3. namespace FitnessCenter
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int visitors = int.Parse(Console.ReadLine());
  10.  
  11.             int back = 0;
  12.             int chest = 0;
  13.             int legs = 0;
  14.             int abs = 0;
  15.             int proteinShake = 0;
  16.             int proteinBar = 0;
  17.  
  18.             for (int i = 0; i < visitors; i++)
  19.             {
  20.                 string activity = Console.ReadLine();
  21.  
  22.                 if (activity == "Back")
  23.                 {
  24.                     back++;
  25.                 }
  26.  
  27.                 if (activity == "Chest")
  28.                 {
  29.                     chest++;
  30.                 }
  31.  
  32.                 if (activity == "Legs")
  33.                 {
  34.                     legs++;
  35.                 }
  36.  
  37.                 if (activity == "Abs")
  38.                 {
  39.                     abs++;
  40.                 }
  41.  
  42.                 if (activity == "Protein shake")
  43.                 {
  44.                     proteinShake++;
  45.                 }
  46.  
  47.                 if (activity == "Protein bar")
  48.                 {
  49.                     proteinBar++;
  50.                 }
  51.             }
  52.  
  53.             int peopleForWorkOut = back + chest + legs + abs;
  54.             int peopleForProtein = proteinShake + proteinBar;
  55.  
  56.             double percentWorkOut = peopleForWorkOut * 1.0 / visitors * 100;
  57.             double percentProtein = peopleForProtein * 1.0 / visitors * 100;
  58.  
  59.             Console.WriteLine($"{back} - back");
  60.             Console.WriteLine($"{chest} - chest");
  61.             Console.WriteLine($"{legs} - legs");
  62.             Console.WriteLine($"{abs} - abs");
  63.             Console.WriteLine($"{proteinShake} - protein shake");
  64.             Console.WriteLine($"{proteinBar} - protein bar");
  65.             Console.WriteLine($"{percentWorkOut:f2}% - work out");
  66.             Console.WriteLine($"{percentProtein:f2}% - protein");
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement