bank
TRANSCRIPT
Assume that a bank maintains two kinds of accounts for customers, one called as saving account and the other as current account. The savings account provides compound interest and withdrawal facilities but no cheque book facility. The current account provides cheque book facility but no interest. Current account holders should also maintain a minimum balance and if the balance falls below this level, a service charge is imposed.Create a class account that stores customer name, account number and type of account. From this derive the classes cur_acct and sav_acct to make them more specific to their requirements. Include necessary member functions in order to achieve the following tasks:a. Accept deposit from a customer and update the balance.b. Display the balancec. Compute and deposit the interestd. Permit withdrawal and update the balancee. Check for the minimum balance, impose penalty, necessary, and update the balance.Do not use any constructors. Use member functions to initialize the class members.
PROGRAM
#include<iostream.h>
#include<conio.h>
class bank
{
protected:
char name[30];
int accno;
public:
void get_name()
{
cout<<"ENTER THE NAME OF CUSTOMER\n";
cin>>name;
}
void get_accno()
{
cout<<"ENTER THE ACCOUNT NUMBER\n";
cin>>accno;
}
void put_name()
{
cout<<name;
}
void put_accno()
{
cout<<accno;
}
};
class savaccount:public bank
{
protected:
float amount,dep,with,interest;
int choice;
public:
void amount1()
{
cout<<"\nENTER THE AMOUNT IN THE SAVING ACCOUNT\n";
cin>>amount;
}
void trans()
{
cout<<"\nBANK TRANSACTIONS\n";
cout<<"1.DEPOSIT\n2.WITHDRAW\n";
cout<<"ENTER WITHDRAWAL OR DEPOSIT\n";
cin>>choice;
switch(choice)
{
case 1:
deposit1();
break;
case 2:
withdraw1();
break;
default:
cout<<"INVALID CHOICE";
}
}
void deposit1()
{
cout<<"ENTER THE AMOUNT TO BE DEPOSITED\n";
cin>>dep;
interest=dep*0.1;
amount=amount+dep+interest;
cout<<"THE BALANCE AMOUNT IS"<<amount<<"\n";
}
void withdraw1()
{
cout<<"ENTER THE AMOUNT TO WITHDRAW\n";
cin>>with;
if(amount>with)
{
amount=amount-with;
cout<<"THE BALANCE AMOUNT IS"<<amount<<"\n";
}
else
cout<<"THE BALANCE IS INSUFFICIENT \n";
}
void display1(bank b)
{
cout<<"ACCOUNT NAME\t"<<"ACCOUNT NUMBER\t"<<"BALANCE"<<"\n";
b.put_name();
cout<<"\t\t";
b.put_accno();
cout<<"\t\t";
cout<<amount;
}
};
class curaccount:public bank
{
protected:
float amount,with,dep;
int choice;
public:
void amount2()
{
cout<<"ENTER THE AMOUNT IN THE CURRENT ACCOUNT\n";
cin>>amount;
if(amount<1000)
{
cout<<"THE BALANCE IS LESS THAN MINIMUM BALANCE";
cout<<"PENALITY IS Rs 400";
cout<<"BALANCE IS"<<amount-400;
}
}
void trans2()
{
cout<<"\nBANK TRANSACTIONS\n";
cout<<"1.DEPOSIT\n2.WITHDRAW\n";
cout<<"ENTER WITHDRAWAL OR DEPOSIT\n";
cin>>choice;
switch(choice)
{
case 1:
deposit2();
break;
case 2:
withdraw2();
break;
default:
cout<<"INVALID CHOICE";
}
}
void deposit2()
{
cout<<"ENTER THE AMOUNT TO BE DEPOSITED\n";
cin>>dep;
amount=amount+dep;
cout<<"THE BALANCE AMOUNT IS"<<amount<<"\n";
}
void withdraw2()
{
cout<<"ENTER THE AMOUNT TO WITHDRAW\n";
cin>>with;
if(amount>with)
{
amount=amount-with;
cout<<"THE BALANCE AMOUNT IS"<<amount<<"\n";
}
else
cout<<"THE BALANCE IS INSUFFICIENT \n";
}
void display2(bank b)
{
cout<<"ACCOUNT NAME\t"<<"ACCOUNT NUMBER\t"<<"BALANCE\n";
b.put_name();
cout<<"\t\t";
b.put_accno();
cout<<"\t\t";
cout<<amount<<"\n";
}
};
int main()
{
int n,type;
clrscr();
cout<<"ENTER THE NUMBER OF CUSTOMERS\n";
cin>>n;
bank b[10];
savaccount s[10];
curaccount c[10];
for(int i=1;i<=n;i++)
{
b[i].get_name();
b[i].get_accno();
}
for(i=1;i<=n;i++)
{
cout<<"\nENTER THE TYPE OF ACCOUNT\n";
cout<<"3.SAVING ACCOUNT\n4.CURRENT ACCOUNT";
cin>>type;
switch(type)
{
case 3:
s[i].amount1();
s[i].trans();
s[i].display1(b[i]);
break;
case 4:
c[i].amount2();
c[i].trans2();
c[i].display2(b[i]);
default:
cout<<"INVALID CHOICE";
}
}
return 0;
}
OUTPUT
ENTER THE NUMBER OF CUSTOMERS
5
ENTER THE NAME OF CUSTOMER
SAM
ENTER THE ACCOUNT NUMBER
1000
ENTER THE NAME OF CUSTOMER
JEYA
ENTER THE ACCOUNT NUMBER
1001
ENTER THE NAME OF CUSTOMER
JOHN
ENTER THE ACCOUNT NUMBER
1002
ENTER THE NAME OF CUSTOMER
SAMPSON
ENTER THE ACCOUNT NUMBER
1003
ENTER THE NAME OF CUSTOMER
BLESSY
ENTER THE ACCOUNT NUMBER
1004
ENTER THE TYPE OF ACCOUNT
3.SAVING ACCOUNT
4.CURRENT ACCOUNT
ENTER THE CHOICE
3
ENTER THE AMOUNT IN THE SAVING ACCOUNT
15500
BANK TRANSACTIONS
1.DEPOSIT
2.WITHDRAW
ENTER WITHDRAWAL OR DEPOSIT
1
ENTER THE AMOUNT TO BE DEPOSITED
5000
THE BALANCE AMOUNT IS21000
ACCOUNT NAME ACCOUNT NUMBER BALANCE
SAM 1000 21000
ENTER THE TYPE OF ACCOUNT
3.SAVING ACCOUNT
4.CURRENT ACCOUNT
ENTER THE CHOICE
3
ENTER THE AMOUNT IN THE SAVING ACCOUNT
155500
BANK TRANSACTIONS
1.DEPOSIT
2.WITHDRAW
ENTER WITHDRAWAL OR DEPOSIT
2
ENTER THE AMOUNT TO WITHDRAW
5000
THE BALANCE AMOUNT IS150500
ACCOUNT NAME ACCOUNT NUMBER BALANCE
JEYA 1001 150500
ENTER THE TYPE OF ACCOUNT
3.SAVING ACCOUNT
4.CURRENT ACCOUNT
ENTER THE CHOICE
4
ENTER THE AMOUNT IN THE CURRENT ACCOUNT
15000
BANK TRANSACTIONS
1.DEPOSIT
2.WITHDRAW
ENTER WITHDRAWAL OR DEPOSIT
1
ENTER THE AMOUNT TO BE DEPOSITED
5000
THE BALANCE AMOUNT IS20000
ACCOUNT NAME ACCOUNT NUMBER BALANCE
JOHN 1002 20000
ENTER THE TYPE OF ACCOUNT
3.SAVING ACCOUNT
4.CURRENT ACCOUNT4
ENTER THE AMOUNT IN THE CURRENT ACCOUNT
600
THE BALANCE IS LESS THAN MINIMUM BALANCE
PENALITY IS Rs 400
BALANCE IS 200
BANK TRANSACTIONS
1.DEPOSIT
2.WITHDRAW
ENTER WITHDRAWAL OR DEPOSIT
1
ENTER THE AMOUNT TO BE DEPOSITED
4500
THE BALANCE AMOUNT IS4700
ACCOUNT NAME ACCOUNT NUMBER BALANCE
SAMPSON 1003 4700
ENTER THE TYPE OF ACCOUNT
3.SAVING ACCOUNT
4.CURRENT ACCOUNT3
ENTER THE AMOUNT IN THE SAVING ACCOUNT
1500
BANK TRANSACTIONS
1.DEPOSIT
2.WITHDRAW
ENTER WITHDRAWAL OR DEPOSIT
2
ENTER THE AMOUNT TO WITHDRAW