fueanta

Standard Bank Account mechanism

Sep 6th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.24 KB | None | 0 0
  1. // Cpp program to introduce the Standard Bank Account coding mechanism
  2. // created on June, 2016
  3. // Author: fueanta
  4.  
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. class Account {
  9.     string acc_name;
  10.     string acc_no;
  11.     double t_balance;
  12. public:
  13.     Account() {
  14.         this->acc_name= "";
  15.         this->acc_no= "";
  16.         this->t_balance= 0.00;
  17.     }
  18.     Account(string,string,double);
  19.     double get_balance() {
  20.         return t_balance;
  21.     }
  22.     void Withdraw(double);
  23.     void Deposit(double);
  24.  
  25.     void Transfer(Account& a, double amount) {
  26.         if (amount < 0)
  27.             amount *= -1;
  28.         if (amount <= t_balance) {
  29.             t_balance -= amount;
  30.             a.t_balance += amount;
  31.             cout << "Tk " << amount << " have been transferred from your account to " << a.acc_name << "'s account." << endl;
  32.         }
  33.         else
  34.             cout << "You do not have sufficient balance." << endl;
  35.         }
  36.         show() {
  37.             cout << "Account Name: " << acc_name << endl;
  38.             cout << "Account Number: " << acc_no << endl;
  39.             cout << "Current Balance: " << t_balance << endl;
  40.         }
  41.         set_info(string name,string no,double balance) {
  42.             acc_name = name;
  43.             acc_no = no;
  44.             t_balance = balance;
  45.             cout << "An account is registered in " << acc_name << "'s name." << endl;
  46.         }
  47. };
  48.  
  49. Account::Account(string name,string no,double balance) {
  50.     acc_name = name;
  51.     acc_no = no;
  52.     this->t_balance = balance;
  53. }
  54. void Account::Withdraw(double amount) {
  55.     if (amount < 0)
  56.         amount *= -1;
  57.     if (amount <= t_balance) {
  58.         t_balance -= amount;
  59.         cout << "Tk " << amount << " have been withdrawn from your account." << endl;
  60.     }
  61.     else
  62.         cout << "You do not have sufficient balance." << endl;
  63. }
  64. void Account::Deposit(double amount) {
  65.     if (amount< 0)
  66.         amount *= -1;
  67.     t_balance += amount;
  68.     cout << "Tk " << amount << " have been added to your account." << endl;
  69. }
  70.  
  71. int main(void) {
  72.     Account a1,a2("Taqui","werty3456",100);
  73.     a1.show(); a2.show();
  74.     a1.set_info("Nahian","dfghjk4567",a1.get_balance());
  75.     a2.Deposit(100); a2.Transfer(a1,-50);
  76.     a1.show(); a2.show();
  77.     return 0;
  78. }
Add Comment
Please, Sign In to add comment