OOCP2_9

//BCA Support //www.bcasupport.xyz #include <iostream.h> #include <conio.h> #include <string.h> class bank { protected: int accno; char cname[20],acctype[8]; public: void getdata() { clrscr(); cout<<"\nEnter A/C no : "; cin>>accno; cout<<"Enter customer name : "; cin>>cname; } }; class savings: public bank { float balance,rate,transfer,intrst; public: savings() { rate=7.5; strcpy(acctype,"Savings"); getdata(); cout<<"\nEnter current balance : Rs. "; cin>>balance; } void deposit() { cout<<"\nEnter amount to deposit : Rs. "; cin>>transfer; balance+=transfer; cout<<"Current balance : Rs. "<<balance; getch(); } int withdraw() { cout<<"\nEnter amount to withdraw : Rs. "; cin>>transfer; if(transfer>balance) { cout<<"\nError. Insufficient balance!"; cout<<"\nCurrent balance : Rs. "<<balance; getch(); return 0; } balance-=transfer; cout<<"Current balance : Rs. "<<balance; getch(); return 0; } void interest() { intrst=(balance*rate)/100; cout<<"\nInterest per year : Rs. "<<intrst; cout<<"\nBalance with interest : Rs. "<<(balance+intrst); getch(); } void print() { clrscr(); cout<<"\n-> Account Details-\nA/C No. : "<<accno; cout<<"\nA/C Type : "<<acctype; cout<<"\nCustomer Name : "<<cname; cout<<"\nCurrent Balance : Rs. "<<balance; cout<<"\nInterest Rate : "<<rate; interest(); } }; class current: public bank { float balance,rate,transfer,intrst; public: current() { rate=4.5; strcpy(acctype,"Current"); getdata(); cout<<"\nEnter current balance : Rs. "; cin>>balance; } void deposit() { cout<<"\nEnter amount to deposit : Rs. "; cin>>transfer; balance+=transfer; cout<<"Current balance : Rs. "<<balance; getch(); } int withdraw() { cout<<"\nEnter amount to withdraw : Rs. "; cin>>transfer; if(transfer>balance) { cout<<"\nError. Insufficient balance!"; cout<<"\nCurrent balance : Rs. "<<balance; getch(); return 0; } balance-=transfer; cout<<"Current balance : Rs. "<<balance; getch(); return 0; } void interest() { intrst=(balance*rate)/100; cout<<"\nInterest per year : Rs. "<<intrst; cout<<"\nBalance with interest : Rs. "<<(balance+intrst); getch(); } void print() { clrscr(); cout<<"\n-> Account Details-\nA/C No. : "<<accno; cout<<"\nA/C Type : "<<acctype; cout<<"\nCustomer Name : "<<cname; cout<<"\nCurrent Balance : Rs. "<<balance; cout<<"\nInterest Rate : "<<rate; interest(); } }; int main() { int ch; while(1) { clrscr(); cout<<"\nSelect account type-\n1. Savings\n2. Current" "\n3. Exit\nEnter choice : "; cin>>ch; if(ch==1) { savings s1; while(1) { clrscr(); cout<<"\n1. Deposit\n2. Withdaw\n3. View Interest" "\n4. View all details\n5. Exit\nEnter choice : "; cin>>ch; switch(ch) { case 1: s1.deposit(); break; case 2: s1.withdraw(); break; case 3: s1.interest(); break; case 4: s1.print(); break; default:return 0; } } } else if(ch==2) { current c1; while(1) { clrscr(); cout<<"\n1. Deposit\n2. Withdaw\n3. View Interest" "\n4. View all details\n5. Exit\nEnter choice : "; cin>>ch; switch(ch) { case 1: c1.deposit(); break; case 2: c1.withdraw(); break; case 3: c1.interest(); break; case 4: c1.print(); break; default:return 0; } } } else return 0; } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.