Advertisement
silvana1303

fitness centre

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