desislava_topuzakova

04. Fitness Center

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