Hi everyone,
basically i have some problem in doing my C++ bank account class.I need to create a base class bank with withdrawal,deposit and calculation of balance where there must be a name, account number and type.
i need also to create derived class Saving of a saving account, which allows overdraft up to $8000 and gives interest of 2% per annum and another derived class Current of a current account, which does not allow overdraft and does not give any interest.
Two objects of the derived classes with initial deposits of $2000 and $5000 each. showing interest calculation for one month and and giving warning when the account balance is zero or less.
Now i am stuck with continuing my work.
This is what i have done so far:
Any help will be appreciated thanks.Code:#include <iostream> #include <iomanip> #include <string> using namespace std; class Bank { protected: char nm[20]; int accno; float damt,wamt,t,bamt,iamt; //amt=amount where d=deposit , w=withdraw, t=total ,b=balance, i=initial(starting amount) public: Bank() {iamt=6000;} void intro(); void deposit(); void withdraw(); void display(); void bal(); void ivalue(); }; void Bank ::intro() { cout<< "\nAccount Name: "; cin>>nm; cout<< "\nAccount No: "; cin>>accno; cout<< "\nType: Saving\n "; } void Bank::ivalue() { iamt=6000; } void Bank ::bal() { cout<<"Balance: $"<<iamt<<endl; } void Bank ::withdraw() { cout<<" \nEnter positive amount to deposit and negative to withdraw: $"; cin>>wamt; t=wamt+iamt; } void Bank ::display() { if(wamt>t) { cout<<nm<<setw(10)<<"Not enough balance to be withdrawn\n"; cout<<"Maximum money can be withdrawn Rs"<<t<<"\n"; } else { cout<<"Balance:"<<t<<endl; } } void main() { Bank jacky; jacky.intro(); jacky.bal(); jacky.withdraw(); jacky.display(); Saving john; john.showinterest(); john.sdisplay(); }
edit:sorry just added code tags



LinkBack URL
About LinkBacks


