Subscribe Us

Responsive Advertisement

Advertisement

Balagurusamy 5.3 exercise solution

 

Balagurusamy 5.3 exercise solution

by ujjal roy



#include<bits/stdc++.h>

#include<conio.h>

using namespace std;

class account

{

    string name;

    int ac_number;

    string type_ac;

    double amount;

public :

    void assign_val()

    {

         system("cls");

        cout<<"Enter your name : ";

        cin>>name;

        cout<<"Enter your account number : ";

        cin>>ac_number;

        cout<<"Enter your account type : ";

        cin>>type_ac;

        cout<<"Enter initial amount : ";

        cin>>amount;

         system("cls");

     cout<<"\nacount create successfully \n\n";

     cout<<"press any key to go main manu : ";

        getch();



    }

  void deposit()

  {

       system("cls");

      int ac;

      cout<<"Enter account number : ";

      cin>>ac;

      if(ac==ac_number)

      {

          double am;

          cout<<"Enter amount : ";

          cin>>am;

          amount+=am;

      }

      else cout<<"Invalid account number\n";

       cout<<"press any key to go main manu : ";

        getch();

  }

  void display1()

  {

       system("cls");

        int ac;

      cout<<"Enter account number : ";

      cin>>ac;

      if(ac==ac_number)

      {



          cout<<"Your name : "<<name<<endl;

        cout<<"Your balance : "<<amount<<endl;


      }

      else cout<<"Invalid account number\n";

       cout<<"press any key to go main manu : ";

        getch();

  }

  void display()

  {

      system("cls");





        cout<<"Your name : "<<name<<endl;

        cout<<"Your balance : "<<amount<<endl;


       cout<<"press any key to withdraw : ";

        getch();

  }

  void withdraw()

  {

       system("cls");

       int ac;

      cout<<"Enter account number : ";

      cin>>ac;

      if(ac==ac_number)

      {

           display();

           system("cls");

          double am;

          cout<<"Enter amount : ";

          cin>>am;

         if(am<=amount)

         {

             cout<<"Withdraw amount : "<<am<<endl;

         }

         else cout<<"Sorry!!! insuficient balance : ";

      }

      else cout<<"Invalid account number\n";

       cout<<"press any key to go main manu : ";

        getch();

  }



};


int main()

{




 while(1)

    {

        system("cls");

        account person1[10];

         int cus;

       cout<<"Enter customer NO(1 to 10) :";

       cin>>cus;

       cus--;

        int choose;

    cout<<"1.create account\n2.log in\n";

    cout<<"Enter choose : ";

    cin>>choose;

        if(choose==1)

         {

          person1[cus].assign_val();

          }

          else

          {

                    system("cls");

              int chose;

              cout<<"1.Deposit\n2.Withdraw\n3.Display name and balance \n";

              cout<<"Enter choose : ";

              cin>>chose;

              if(chose==1)

              {

                  person1[cus].deposit();

              }

           else if(chose==2) person1[cus].withdraw();

         else if(chose==3)person1[cus].display1();

         else cout<<"Invalid choose\n";


          }

    }




    return 0;

}


Post a Comment

0 Comments