

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Account Class- Withdraw, deposit and calculate interest
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!
Account Class
#include
void deposit() { cout << endl << "Please enter the amount to be deposited:" << endl; cin >> deposit_amount; cout << endl; }
void withdraw() { cout << endl << "Please enter the amount to be withdrawn:" << endl; cin >> withdraw_amount; cout << endl; remaining_amount=deposit_amount-withdraw_amount; cout << endl << "Remaining amount after withdrawn:" << remaining_amount<<endl; }
void calculate_interest() { cout <<" Principle Amount to calculate interest: "; cin>>p ; cout<<" Rate of Interest : "; cin>>r; cout <<" Number of years : "; cin>>t; si= (p rt) /100; Tot_amount = si + p; cout<<endl<<"Interest : "<<si; cout<<endl<<"Total Amount : "<<Tot_amount;
int main() { int selection; account obj; do { cout << "Please make a selection:" << endl; cout << "1.) Deposit" << endl; cout << "2.) Withdraw" << endl; cout << "3.) Calculate vInterest" << endl; cout << "4.) Quit" << endl; cin >> selection; if(selection == 1) { obj.deposit(); } if(selection==2) { obj.withdraw(); } if(selection==3) { obj.calculate_interest(); } }while(selection != 4); return 0; }