madeofglass

Untitled

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