fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <ctime>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <string>
  7. #define ll long long
  8. using namespace std;
  9. class banking_sys
  10. {
  11. private:
  12. string owner;
  13. double balance;
  14. public:
  15. // settr owners name
  16. void set_owner(string owner)
  17. {
  18. this->owner = owner;
  19. }
  20. // gettr owners name
  21. string get_owner()
  22. {
  23. return owner;
  24. }
  25. // settr acc money
  26. void set_balance(double balance)
  27. {
  28. if (balance > 0)
  29. {
  30. this->balance = balance;
  31. }
  32. else
  33. {
  34. cout << "Sorry, your account is empty." << " \U0001F494 " << endl;
  35. }
  36. }
  37. // gettr acc money
  38. double get_balance()
  39. {
  40. return balance;
  41. }
  42. // add to acc
  43. void add_money (double added)
  44. {
  45. cout << "your balance now is : " << balance << "\n";
  46. balance += added;
  47. cout << "The mony that was added is: " << added << "\n";
  48. cout << "your balance becomes : " << balance << "\n";
  49. }
  50. // to take mony
  51. void take_money(double taken)
  52. {
  53. if (taken > balance)
  54. {
  55. cout << "5aleek mo7tarm mtb2ash 7aramy. " << "\n";
  56. }
  57. else if (taken <= balance)
  58. {
  59. cout << "you took : " << taken << "\n";
  60. if (taken == balance)
  61. {
  62. cout << "Now, your account is empty." << "\n";
  63. }
  64. else if (taken < balance)
  65. {
  66. cout << "Now, your account is : " << balance - taken << "\n";
  67. }
  68. }
  69. }
  70.  
  71.  
  72. banking_sys (string owner, double balance) :owner (owner), balance(balance)
  73. {
  74. cout << "Hello, we are happy for banking with us." << " \U0001F60D " << endl;
  75. }
  76. ~banking_sys()
  77. {
  78. cout << "Thank you for banking with us " << "\U0001F60D" << "\n";
  79. }
  80. };
  81. int main() {
  82. string owner;
  83. double balance;
  84. cin >> owner >> balance;
  85. banking_sys customer1(owner, balance);
  86. customer1.set_balance(balance);
  87. // to confirm yes = 1 or no = 0
  88. bool choice;
  89. cout << "Do you want to add mony ? \n";
  90. cin >> choice;
  91. if (choice == 1)
  92. {
  93. double added;
  94. cout << "enter how much do you want to add :\n";
  95. cin >> added;
  96. customer1.add_money(added);
  97. }
  98. else if (choice == 0)
  99. {
  100. cout << "Ok, for taking mony enter how much do you want to take \n";
  101. double taken;
  102. cin >> taken;
  103. customer1.take_money(taken);
  104. }
  105. return 0;
  106. }
Success #stdin #stdout 0s 5268KB
stdin
Standard input is empty
stdout
Hello, we are happy for banking with us. 😍 
Do you want to add mony ? 
Ok, for taking mony enter how much do you want to take 
you took : 1.15211e-310
Now, your account is : 1.42291e-321
Thank you for banking with us 😍