Wednesday, March 28, 2018

Write a C++ program to fill a Bank Application


AIM: Write a C++ program for Bank Application
SOURCE CODE:
#include<iostream>
#include<string.h>
using namespace std;
class Bank
{
            int account_no;
            char name[20];
            float balance;
            public:
            void display()  {
                        cout<<"\n account_no:"<<account_no<<endl;
                        cout<<"\n name:"<<name<<endl;
                        cout<<"\n balance:"<<balance<<endl;
            }         
            Bank(int x,char *y,float z){
                        account_no=x;
                        strcpy(name,y);
                        balance=z;
            }
            void Credit()   {
                        float amount;
                        display();
                        cout<<"\n enter amount:";
                        cin>>amount;
                        balance=balance+amount;
                        display();
            }
            void Debit()    {
                        float amount;
                        display();
                        cout<<"\n enter amount:";
                        cin>>amount;
                        if(balance<amount){
                                    cout<<"\n insufficient balance";
                        }
                        else{
                                    balance=balance-amount;
                        }
                        display();
            }
};
int main(){
            Bank bl(101,"BALA",1000);
            int ch;
            do{
                        cout<<"\n 1.Debit"<<"\n 2.Credit"<<"\n 3.exit"<<"\n";
                        cout<<"\n enter the case:"<<"\n";
                        cin>>ch;
                        switch(ch)
                        {
                                    case 1:bl.Debit();
                                         break;
                                    case 2:bl.Credit();
                                           break;
                            case 3:exit(0);
                            default:cout<<"\ invalid choice";                                               
                        }
            }while(1);
}

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home