1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
#include <iostream>
#include <string>
#include "Header.h"
using namespace std;
class Account{
private:
string firstname;
string lastname;
int accountnumber;
double balance;
public:
Account();
Account(string FName,string LName,int accno,double bal);
void setAccountNumber(int accno);
void setBalance(double bal);
void setWithdraw(int wdraw,double bal);
void setDeposit(int dep,double bal);
string getFullName(string fName,string lName);
void display(string FName,string LName);
};
Account::Account(){
firstname="Raaj";
lastname="Lokanathan";
accountnumber=5671;
balance=0.0;
}
Account::Account(string FName,string LName,int accno,double bal){
firstname = FName;
lastname = LName;
accountnumber = accno;
balance = bal;
}
void Account::setAccountNumber(int accno){
accountnumber = accno;
}
void Account::setBalance(double bal){
balance = bal;
}
void Account::setWithdraw(int wdraw,double bal){
if(bal>=wdraw){
wdraw=bal-wdraw;
cout<<"Your current balance is: "<<wdraw<<endl;
}else{
cout<<"No money"<<endl;
}
}
void Account::setDeposit(int dep,double bal){
dep=dep+bal;
cout<<"Your current balance is: "<<dep<<endl;
}
string Account::getFullName(string FName,string LName){
string FullName,x=" ";
LName=x+LName;
return FullName=FName+LName;
}
void Account::display(string FName,string LName){
cout<<"First Name: "<<FName<<endl;
cout<<"Last Name: "<<LName<<endl;
cout<<"Full Name: "<<getFullName(FName,LName)<<endl;
cout<<"Account Number: "<<accountnumber<<endl;
cout<<"Current Balance: "<<balance<<endl;
}
class CurrentAccount:public Account{
private:
double overdraftlimit;
public:
CurrentAccount();
CurrentAccount(string FName,string LName,int accno,double bal,double overd):Account(FName,LName,accno,bal){
overdraftlimit=overd;
}
void setOverdraftLimit(double overd);
double getOverdraftLimit(double overd);
void display();
};
CurrentAccount::CurrentAccount(){
overdraftlimit=0.0;
}
CurrentAccount::CurrentAccount(string FName,string LName,int accno,double bal,double overd):Account(FName,LName,accno,bal){
overdraftlimit=overd;
}
void CurrentAccount::setOverdraftLimit(double overd){
double bal=0;
double wdraw;
if(bal==0){
if(bal>=overd){
wdraw=bal-wdraw;
cout<<"The revised balance is"<<wdraw<<endl;
}else{
cout<<"You cant access this funtion currently"<<endl;
}
}
}
double CurrentAccount::getOverdraftLimit(double overd){
return overd;
}
void CurrentAccount::display(){
Account::display(string FName,string LName);
}
int main(){
Account Acc;
Account acc[5];
CurrentAccount Curr;
string first_name;
string last_name;
int acc_no,choice,Wdraw,Dep,chose;
double bAl,Overd;
int i;
cout<<"-------------------------------"<<endl;
cout<<"Welcome to Raaj Banking System"<<endl;
cout<<"-------------------------------"<<endl;
cout<<"Choose your account type below:"<<endl;
cout<<"(1) Current Account"<<endl;
cout<<"(2) Saving Account"<<endl;
cout<<"Choose wisely: ";
cin>>chose;
for(i=0;i<5;i++){
switch (chose){
case 1:
cout<<"Please enter the amount you wish to withdraw: ";
cin>>Wdraw;
Curr.setOverdraftLimit(Overd);
break;
case 2:
cout<<"EXIT"<<endl;
break;
}
}
for(i=0;i<5;i++){
cout<<"Please enter the details for the customer: "<<i+1<<endl;
cout<<"Please enter your first name: ";
cin>>first_name;
cout<<"Please enter your last name: ";
cin>>last_name;
cin.ignore();
cout<<"Please enter your account number: ";
cin>>acc_no;
cout<<"Please enter your current balance: ";
cin>>bAl;
cout<<"----------------------------------------------------"<<endl;
Acc.getFullName(first_name,last_name);
Acc.setAccountNumber(acc_no);
Acc.setBalance(bAl);
Acc.display(first_name,last_name);
cout<<"----------------------------------------------------"<<endl;
cout<<"Please choose an option: "<<endl;
cout<<"(1) Withdraw"<<endl;
cout<<"(2) Deposit"<<endl;
cout<<"(3) EXIT"<<endl;
cout<<"-----------------------------------------------------"<<endl;
cout<<"Please enter your choice: ";
cin>>choice;
switch(choice){
case 1:
cout<<"Please enter the amount you wish to withdraw: ";
cin>>Wdraw;
Acc.setWithdraw(Wdraw,bAl);
break;
case 2:
cout<<"Please enter the amount you wish to deposit: ";
cin>>Dep;
Acc.setDeposit(Dep,bAl);
break;
case 3:
cout<<"Try again"<<endl;
break;
}
}
system("pause");
}
|