You must Sign In to post a response.
  • Category: Programming

    Program to illustrate normal banking transaction using C++.


    Are you facing difficulty in writing C++ program? Want to know the program solution for normal banking transactions : withdrawal and display of balance in account using constructor? On this Ask Expert page you can scroll through the program solution.

    Following is a question that was asked in the question paper of B.E. Mechanical Engineering (June/July 2017)conducted by Bangalore University, for subject Object Oriented Programming(2K11 Scheme)(ME-601), Semester-VI

    This question is asked for 10 marks and hence requires some explanation. Please let me know the solution.

    Q) Write a C++ program to illustrate normal banking transaction such as deposit, withdraw, balance and display. Use a constructor to input initial values of an object. [10 Marks]
  • Answers

    1 Answers found.
  • Below is the program which performs basic banking operations like new account opening, displaying account information, deposit required amount, withdraw required amount. Program uses switch statement for developing menu driven program.
    Please include , , , header files before class declaration.

    //NORMAL BANKING OPERATIONS USING MENU DRIVEN PROGRAM.
    #include
    #include
    #include
    #include
    class bank
    {
    private:
    char * name;
    int accno;
    float bal;
    public:
    bank(char *s, int acc, float t)
    {
    strcpy(name,s);
    accno=acc;
    bal=t;
    }
    void display(void)
    {
    cout<<"\nName of account holder is "< cout<<"\nAccount number is "< cout<<"\nBalance amount is "< }
    void deposite(float temp)
    {
    bal=bal+temp;
    }
    void withdraw(float w)
    {
    if(bal<=500)
    {
    cout<<"\nYou have insufficient balance to withdraw\n";
    }
    else
    {
    bal=bal-w;
    cout<<"\nAfter withdrawing rupees "< }
    }
    };
    void main(void)
    {
    int ac,op;
    char *na;
    float de,wd;
    char ch;
    clrscr();
    do
    {
    cout<<"1.Opening New account\n2.Display\n3.Deposite\n4.Withdraw\n5.Exit\n";
    cout<<"Enter your option\n";
    cin>>op;
    switch(op)
    {
    case 1:
    cout<<"\nEnter account holder name, account number and amount to open account\n";
    cin>>na>>ac>>de;
    class bank b(na,ac,de);
    break;
    case 2:
    cout<<"\nAccount details are as follows\n";
    b.display();
    break;
    case 3:
    cout<<"Enter amount to be deposited\n";
    cin>>de;
    b.deposite(de);
    break;
    case 4:
    cout<<"Enter amount to be withdraw\n";
    cin>>wd;
    b.withdraw(wd);
    break;
    case 5:
    exit(0);
    break;
    default:
    cout<<"\nInvalid option\n";
    }
    cout<<"\nDo you want to continue if yes enter y/Y and if not enter n/N\n";
    cin>>ch;
    clrscr();
    }while(ch=='y'||ch=='Y');
    getch();
    }


  • Sign In to post your comments