C++ LAB

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART- B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8

old

PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14 . . .

Write a c++ program to define a class Bank Account including the following class members. DataMembers:, cust name, accno, balance. Member Functions: a) getdata(custname,accno,balance). b) display(accno). c) deposit(acno,amt). d) withdrow(accno,amt) updation aftern checking the balance. e) To display name & balance of all the records

 
 #include< iostream .h >
#include< stdio.h >
#include< string.h >

using namespace std;

class bank
{
        int acno;
        char custname[100] ;
        float bal;  
   public:
   void     getData(int acc_no, char *name , float balance) 
        {
                acno=acc_no;
                strcpy(custname, name);
                  bal=balance;
        }
        void deposit();
        void withdraw();
        void display();
};
void bank::deposit()   //depositing an amount
{
        int damt1;
        cout<<"\n Enter Deposit Amount = ";
        cin>>damt1;
        bal+=damt1;
}
void bank::withdraw()  //withdrawing an amount
{
        int wamt1;
        cout<< "\n Enter Withdraw Amount = ";
        cin>>wamt1;
        if(wamt1>bal || bal < 1000)
                cout<< "\n Cannot Withdraw Amount";
        bal-=wamt1;
}
void bank::display()  //displaying the details
{
        cout<<"\n ----------------------";
        cout<<"\n Accout No. : "<< acno;
        cout<<"\n Name : "<< custname;
            cout<<"\n Balance : "<< bal;  
}
int main()
{
        int acc_no;
        char name[100] ;
        float balance;
        cout<<"\n Enter Details: \n";
        cout<<"-----------------------";
        cout<< "\n Accout No. ";
        cin >>acc_no;
        cout<<"\n Name : ";
        cin>>name;
        cout<<"\n Balance : ";
        cin>>balance;
  
        bank b1;
		b1.getData(acc_no, name,  balance);  //object is created
     
  int ch=0;
while(1){
cout<<"\n 1 . deposite  2. withdraw 3. display 4. exit : ";

        cin>>ch;
switch(ch){
case 1:
 
  b1.deposit(); break;
case 2:
        b1.withdraw(); // calling member functions
break;
case 3:       
 b1.display(); break ;//
case 4: return 0;
}}
        return 0;
}