VUSuperior Chat Room

Sunday, 7 December 2014

CS304 Object Oriented Programming Assignment Solution by Khadija

#include <iostream>
using namespace std;

class account{
private:
int accountNo;
float balance;
string bankName;
int b_code;
public:
account(){
accountNo=00;
balance=0.0;
bankName="Default";
b_code=00;
}

account(int ac_num, float bal, string b_name, int code)
{
accountNo=ac_num;
balance=bal;
bankName=b_name;
b_code= code;
}

void withdraw(float draw_money)
{
if (balance<draw_money){
cout <<"\n\a \"Insufficient balance.......\"";
}
else{
balance-=draw_money;
}
}

void deposit(float add_money)
{
balance+=add_money;
}
float getBalance(){
return balance;
}
int getAccountNo(){
return accountNo;
}
string getBankName(){
return bankName;
}
int getBrachCode(){
return b_code;
}
};
class customer{
private:
string name;
string address;
public:
account ac;
customer(string n, string a, account acc)
{
name= n;
address=a;
ac=acc;
}

void display(){
cout<<"\n Customer Name:"<<name;
cout<<"\n Customer Address: "<<address;
cout<<"\n Bank Name: "<<ac.getBankName();
cout<<"\n Branch Code: "<<ac.getBrachCode();
cout<<"\n Current Balance: "<<ac.getBalance();
cout<<"\n Account No. "<<ac.getAccountNo();
}
};

main(){
cout<<"Displaying Customer Account Information"<<endl<<endl;
account obj(20, 10000, "Habib Bank", 123); // Creating an account Obj
customer obj1("Ahmad", "Lahore",obj ); // Creating an customer Obj
obj1.display();

float dep, draw;
cout <<"\n\n Please Enter a value for Deposit: ";
cin >> dep;
obj1.ac.deposit(dep);
cout <<"\n\n Current Balance after Depositing...";
obj1.display();

cout <<"\n\n Please Enter a value for Withdrawl: ";
cin >> draw;
obj1.ac.withdraw(draw);
cout <<"\n\n Current Balance after withdrawing...";
obj1.display();
cout <<endl;
system("pause");
}

0 comments:

Post a Comment