Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Cpp program to introduce the Standard Bank Account coding mechanism
- // created on June, 2016
- // Author: fueanta
- #include <iostream>
- using namespace std;
- class Account {
- string acc_name;
- string acc_no;
- double t_balance;
- public:
- Account() {
- this->acc_name= "";
- this->acc_no= "";
- this->t_balance= 0.00;
- }
- Account(string,string,double);
- double get_balance() {
- return t_balance;
- }
- void Withdraw(double);
- void Deposit(double);
- void Transfer(Account& a, double amount) {
- if (amount < 0)
- amount *= -1;
- if (amount <= t_balance) {
- t_balance -= amount;
- a.t_balance += amount;
- cout << "Tk " << amount << " have been transferred from your account to " << a.acc_name << "'s account." << endl;
- }
- else
- cout << "You do not have sufficient balance." << endl;
- }
- show() {
- cout << "Account Name: " << acc_name << endl;
- cout << "Account Number: " << acc_no << endl;
- cout << "Current Balance: " << t_balance << endl;
- }
- set_info(string name,string no,double balance) {
- acc_name = name;
- acc_no = no;
- t_balance = balance;
- cout << "An account is registered in " << acc_name << "'s name." << endl;
- }
- };
- Account::Account(string name,string no,double balance) {
- acc_name = name;
- acc_no = no;
- this->t_balance = balance;
- }
- void Account::Withdraw(double amount) {
- if (amount < 0)
- amount *= -1;
- if (amount <= t_balance) {
- t_balance -= amount;
- cout << "Tk " << amount << " have been withdrawn from your account." << endl;
- }
- else
- cout << "You do not have sufficient balance." << endl;
- }
- void Account::Deposit(double amount) {
- if (amount< 0)
- amount *= -1;
- t_balance += amount;
- cout << "Tk " << amount << " have been added to your account." << endl;
- }
- int main(void) {
- Account a1,a2("Taqui","werty3456",100);
- a1.show(); a2.show();
- a1.set_info("Nahian","dfghjk4567",a1.get_balance());
- a2.Deposit(100); a2.Transfer(a1,-50);
- a1.show(); a2.show();
- return 0;
- }
Add Comment
Please, Sign In to add comment