Advertisement
Sanlover

Untitled

Oct 27th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <conio.h>
  4. #include <string>
  5.  
  6. const size_t LOW_BORDER = 10;
  7. const size_t HIGH_BORDER = 50;
  8.  
  9. bool add(size_t age, std::string name, std::string surname)
  10. {
  11. if (age > LOW_BORDER && age < HIGH_BORDER)
  12. return true;
  13. else
  14. return false;
  15. }
  16.  
  17. int main()
  18. {
  19. bool isRunning = true;
  20. char key;
  21.  
  22. while (isRunning)
  23. {
  24. system("cls");
  25. std::cout << "1) Add member" << std::endl << "2) B" << std::endl << "3) C" << std::endl << "4) Exit" << std::endl;
  26.  
  27. if (!_kbhit())
  28. {
  29. key = _getch();
  30.  
  31. switch (key)
  32. {
  33. case '1':
  34.  
  35. {std::string name, surname;
  36. size_t age;
  37.  
  38. system("cls");
  39. std::cout << "Pls enter the prarameters down below:" << std::endl << "Name = ";
  40. std::getline(std::cin, name);
  41. std::cout << "Surname = ";
  42. std::getline(std::cin, surname);
  43. std::cout << "Age = ";
  44. std::cin >> age;
  45.  
  46. if (add(age, name, surname))
  47. std::cout << std::endl << "User is succesfully added" << std::endl;
  48. else
  49. std::cout << std::endl << "User is not added" << std::endl;
  50.  
  51. Sleep(2000);
  52. }break;
  53.  
  54. case '4':
  55. isRunning = false;
  56. break;
  57. }
  58. }
  59. }
  60.  
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement