You are on page 1of 3

#include <iostream> class Bank_Account { private: char pname[20]; unsigned int acnum; char actype [10] ; float ac_bal;

public: Bank_Account() {acc_bal = 0.00; } // constructor void get_data() ; void deposit() ; void withdraw(); void showdata() ; }; void Bank_Account :: get_data() { cout << "\nEnter your name: ";<<endl ; cin >> pname; cout<<"Enter the account type : "<<endl ; cin>>actype; cout << "\nEnter current account balance: "<<endl; cin >> ac_bal; } void Bank_Account::deposit() { int acnum; float dep; cout<<" Enter the Account number : "; cin>>acnum; if(acnum!=actype) { cout<<"Opps! Have u entered wrong account number :"; } else { cout << "\nEnter amount to be deposited: "; cin >> dep; acc_bal += dep; } } void Bank_Account::withdraw() { float wdraw;

if(acnum!=actype) { cout<<"Opps! Have u entered wrong account number :"; } else { if(acc_bal == 1000.0f) { cout <<"U cannot withdraw a money from ur acoount"; } cout << "\nEnter amount to be withdrawn: "; cin >> wdraw; else { acc_bal -= wdraw; } } } void Bank_Account :: show_data() { cout << "Name: " << pname; cout << "\nAccount number: " << acnum; cout<<"\n Account type "<<actype; cout << "\nAccount Balance: " << acc_bal << endl; } int main() { int choice; int count = 0; int recnum; Bank_Account bk[10]; do { cout cout cout cout cout cout cout << << << << << << << "\t\t\n\n" << "Main Menu"; "\t\n" << "1 - Add a customer."; "\t\n" << "2 - Deposit money."; "\t\n" << "3 - Withdraw money."; "\t\n" << "4 - Show Account Information."; "\t\n" << "5 - Quit Application.\n\n"; "\t" << "Choice: ";

cin>>choice;

switch(choice) { case 1: system("cls"); if (count > 10) { cout << "Can't add anymore records. Press any key to return to ma in menu."; break; } count += 1; bk[count].getdata(); system("cls"); break; case 2: system("cls"); bk[count].deposit(); system("cls"); break; case 3: system("cls"); /* cout << "\nEnter customer number: "; cin >> recnum;*/ bk[count].withdraw(); system("cls"); break; case 4: system("cls"); /* cout << "\nEnter customer number: "; cin >> recnum; */ bk[count].showdata(); system("cls"); break; case 5: exit (EXIT_FAILURE); break; default: cout << "\nInvalid selection. Press a key to return to main menu."; }

}while(choice!=5); return 0; }

You might also like