Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class BankAccount {
  6. private: // Accessible only to members
  7. string accID;
  8. double accBalance;
  9. string accName;
  10. double interest;
  11.  
  12. public: // Accesible to everyone
  13.  
  14. BankAccount()
  15. : accID("00000-00000"), accName(""), accBalance(0), interest(0) {}
  16.  
  17. BankAccount(string accID_in, string accName_in, double accBalance_in, double interest_in)
  18. : accID(accID_in), accName(accName_in), accBalance(accBalance_in), interest(interest_in) {}
  19.  
  20. string GetID() {
  21. return accID;
  22. }
  23. string GetName() {
  24. return accName;
  25. }
  26.  
  27. double GetBalance() {
  28. return accBalance;
  29. }
  30.  
  31. double GetInterest() {
  32. return interest;
  33. }
  34.  
  35. void IncreaseBalance(int balance) {
  36. accBalance += balance;
  37. }
  38.  
  39. void DecreaseBalance(int balance) {
  40. accBalance -= balance;
  41. }
  42.  
  43. void addDailyInterest() {
  44. accBalance = accBalance + (accBalance * interest);
  45. }
  46.  
  47. void Deactivated(string ID) {
  48. accID = "0000-0000";
  49. accBalance = 0;
  50. accName = "";
  51.  
  52. }
  53.  
  54. bool isActive() {
  55. if (accID == "00000-00000" && accName == "") { // Do checks here
  56. return false; // Return true or false based on checks
  57. }
  58.  
  59. else {
  60. return true;
  61. }
  62. }
  63.  
  64. void SetHolderName(string newName) {
  65. accName = newName;
  66. }
  67.  
  68. void print() {
  69. cout << "Account ID is: " << accID << endl;
  70. cout << "Account balance is: " << accBalance << endl;
  71. cout << "Account name is: " << accName << endl;
  72. cout << "Daily interest is: " << interest << endl;
  73. }
  74.  
  75. };
  76.  
  77. int main()
  78. {
  79.  
  80. BankAccount b1;
  81.  
  82. if (b1.isActive() == true) {
  83. cout << "Your account is active" << endl;
  84. }
  85.  
  86. else {
  87. cout << "Your account is deactivated" << endl;
  88. }
  89.  
  90. cout << "Account ID is: " << b1.GetID() << endl;
  91. cout << "Account balance is: " << b1.GetBalance() << endl;
  92. cout << "Account name is: " << b1.GetName() << endl;
  93. cout << "Daily interest is: " << b1.GetInterest() << endl << endl;
  94.  
  95.  
  96. BankAccount b2("12345-67890", "Brandon", 1000, .7);
  97.  
  98. if (b2.isActive() == true) {
  99. cout << "Your account is active" << endl;
  100. }
  101.  
  102. else {
  103. cout << "Your account is deactivated" << endl;
  104. }
  105. b2.SetHolderName("Ryan");
  106. b2.print();
  107.  
  108. b2.addDailyInterest();
  109.  
  110. b2.IncreaseBalance(500);
  111.  
  112. // New balance
  113.  
  114. cout << "New balance is: " << b2.GetBalance() << endl;
  115.  
  116.  
  117. // New balance
  118.  
  119. b2.DecreaseBalance(750);
  120.  
  121. cout << "New balance is: " << b2.GetBalance() << endl;
  122.  
  123. return 0;
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement