Advertisement
desislava_topuzakova

04. Fitness Center

Feb 18th, 2023
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int countVisitors;
  8. cin >> countVisitors;
  9. cin.ignore();
  10.  
  11. //за всеки един посетител
  12. //повтаряме: въвежда дейността
  13. //начало: първи посетител (1)
  14. //край: последния посетител (countVisitors)
  15. //промяна: +1
  16.  
  17. int countBack = 0, countChest = 0, countLegs = 0, countAbs = 0, countShake = 0, countBar = 0;
  18.  
  19. for (int visitor = 1; visitor <= countVisitors; visitor++)
  20. {
  21. string activity; //"Back", "Chest", "Legs", "Abs", "Protein shake" или "Protein bar"
  22. getline(cin, activity);
  23.  
  24. //проверка каква дейност имаме
  25. if (activity == "Back")
  26. {
  27. countBack++;
  28. }
  29. else if (activity == "Chest")
  30. {
  31. countChest++;
  32. }
  33. else if (activity == "Legs")
  34. {
  35. countLegs++;
  36. }
  37. else if (activity == "Abs")
  38. {
  39. countAbs++;
  40. }
  41. else if (activity == "Protein shake")
  42. {
  43. countShake++;
  44. }
  45. else if (activity == "Protein bar")
  46. {
  47. countBar++;
  48. }
  49.  
  50. }
  51.  
  52. cout << countBack << " - back" << endl;
  53. cout << countChest << " - chest" << endl;
  54. cout << countLegs << " - legs" << endl;
  55. cout << countAbs << " - abs" << endl;
  56. cout << countShake << " - protein shake" << endl;
  57. cout << countBar << " - protein bar" << endl;
  58.  
  59.  
  60. cout.setf(ios::fixed);
  61. cout.precision(2);
  62.  
  63. //какъв процент от всички тренират
  64. int countTrain = countBack + countChest + countAbs + countLegs; //брой трениращи
  65. double percentTrain = (countTrain * 1.0 / countVisitors) * 100;
  66. cout << percentTrain << "% - work out" << endl;
  67.  
  68. //какъв процент от всички са купували
  69. int countBuy = countShake + countBar; //брой пазаруващи
  70. double percentBuy = (countBuy * 1.0 / countVisitors) * 100;
  71. cout << percentBuy << "% - protein" << endl;
  72.  
  73. }
  74.  
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement