Please need help on following program using C language Which
Please need help on following program using C++ language. Whichshould include header file, implementation file, and test program. Please provide seprate files.
(a) Define the class bankAccount to store a bank customer’s account number and balance. Suppose that accountNumber is of type int, and balance is of type double. Add appropriate constructors. Your class should, at least, provide the following operations:
set the account number,
retrieve the account number,
retrieve the balance,
deposit and withdraw money
print account information
(b) Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount (designed in part (a)). This class inherits members to store the account number and the balance from the base class. A customer with a checking account typically receives interest, maintains a minimum balance, and pays service charges if the balance falls below the minimum balance. Add member variables to store this additional information. Add appropriate constructors. In addition to the operations inherited from the base class, this class should provide the following operations:
set interest rate,
retrieve interest rate,
set minimum balance,
retrieve minimum balance,
set service charges,
retrieve service charges,
post interest,
verify if the balance is less than the minimum balance,
write a check,
withdraw (override the method of the base class),
and print account information.
(c) Every bank offers a savings account. Derive the class savingsAccount from the class bankAccount (designed in part (a)). This class inherits members to store the account number and the balance from the base class. A customer with a savings account typically receives interest, makes deposits, and withdraws money. Add appropriate constructors. In addition to the operations inherited from the base class, this class should provide the following operations:
set interest rate,
retrieve interest rate,
post interest,
withdraw (override the method of the base class),
and print account information. Add appropriate constructors.
Write a program to test your classes designed in parts (b) and (c). Your test program does not have to simulate a bank. All it needs to do is test the functions you wrote for your classes.
Solution
BANK ACCOUNT CLASS:-
#include<iostream.h>
#include<conio.h>
class bankAccount{
protected:
int account_num;
double bal;
public :
bankAccount(){
}
bankAccount(int acc_num,int b)
{
account_num= acc_num;
bal=b;
}
void setAccountNum(int a)
{
account_num=a;
}
int getAccountNum()
{
return account_num;
}
double depositMoney(double d)
{
bal= bal+d;
return bal;
}
double withdrawMoney(double d)
{ if (bal<=0)
{cout<<\"Insufficient balance \";
return (0);
}
bal = bal-d;
return bal;
}
void printAcountInfo()
{
cout<<\"Account number : \"<<account_num;
cout<<\"\ Balance :\"<<bal;
}
} ;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CHECK ACCOUNT:-
class checkAccount: bankAccount{
private :
float int_rate;
double min_bal;
float service_chgs;
public:
checkAccount()
{
}
checkAccount(int ac,double b,float ir,double mb,float sc)
{ account_num=ac;
bal= b;
int_rate=ir;
min_bal=mb;
service_chgs=sc;
}
void setintrestRate(float f)
{ int_rate=f;
}
float getintrestRate(){
return int_rate;
}
void setMinBal(double d)
{ min_bal=d;
}
double getMinBal(){
return min_bal;
}
void setServiceCharges(float f)
{service_chgs=f;
}
float getServiceCharges(){
return service_chgs;
}
int check ()
{ if(bal>min_bal)
{ cout<<\"Balance greater than minimum balance \"<< bal;
return 1; }
else
{
cout<<\"Balance less than minimum balance \"<<bal;
return 0;
}
}
double withdrawMoney(double d){
if(check()==0){
bal=bal-service_chgs ;
if(bal <=0)
return 0;
bal = bal-d;
return bal;
}
bal = bal-d;
return bal;
}
void printAcountInfo()
{
cout<<\"Account number : \"<<account_num;
cout<<\"\ Balance :\"<<bal;
cout<<\"\ Minimum Balance required:\"<<min_bal;
cout<<\"\ Service Charges\"<<service_chgs;
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVING ACCOUNT CLASS:-
class savingAccount : bankAccount{
private :
float intrest_rate;
public :
savingAccount( int ac, double b,float ir)
{ account_num=ac;
bal= b;
intrest_rate=ir;
}
savingAccount()
{
}
void setIntrestRate(float f)
{
intrest_rate=f;
}
float getIntrestRate()
{
return intrest_rate;
}
double withdrawMoney(double d)
{ if (bal<=0)
{cout<<\"Insufficient balance \";
return (0);
}
bal = bal-d;
return bal;
}
void printAcountInfo()
{
cout<<\"Account number : \"<<account_num;
cout<<\"\ Balance :\"<<bal;
cout<<\"\ Intrest Rate :\"<<intrest_rate;
}
};



