Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This lab introduces you to writing a C++ program to implement the concept of cla

ID: 3567557 • Letter: T

Question

This lab introduces you to writing a C++ program to implement the concept of class inheritance using different types of bank accounts as a model.

In this lab, you will create a base class, called CBankAccount, and two additional classes (each derived from CBankAccount), called CSavingsAccount and CCheckingAccount. You will then test the operations of each class in function main() to simulate the transactions of both a checking account and a savings account.

This is a multi-file project.

#Include each file as needed and indicate when once file begins and one ends.

The BankAccount class should contain, at minimum, the following members.

A.

B.

The class CheckingAccount should contain, at a minimum, the following members.

C.

The class CheckingAccount should contain, at a minimum, the following members.

D

Explanation / Answer

#include <iostream.h>
#include <conio.h>

class CBankAccount
{
char cust_name[20];
int acc_no;
char acc_type[20];
public:
   void get_accinfo()
   {
       cout<<" Enter Customer Name :- ";
       cin>>cust_name;
       cout<<"Enter Account Number :- ";
       cin>>acc_no;
       cout<<"Enter Account Type :- ";
       cin>>acc_type;
   }
   void display_accinfo()
   {
       cout<<" Customer Name :- "<<cust_name;
       cout<<" Account Number :- "<<acc_no;
       cout<<" Account Type :- "<<acc_type;
   }
};

class CCheckingAccount : public CBankAccount
{
staticfloat balance;
public:
    void disp_currbal()
    {
      cout<<" Balance :- "<<balance;
    }
    void deposit_currbal()
    {
      float deposit;
      cout<<" Enter amount to Deposit :- ";
      cin>>deposit;
      balance = balance + deposit;
    }
    void withdraw_currbal()
    {
      float penalty,withdraw;
      cout<<" Balance :- "<<balance;
      cout<<" Enter amount to be withdraw :-";
      cin>>withdraw;
      balance=balance-withdraw;
      if(balance < 500)
      {
      penalty=(500-balance)/10;
      balance=balance-penalty;
      cout<<" Balance after deducting penalty : "<<balance;
      }
      elseif(withdraw > balance)
      {
      cout<<" You have to take permission for Bank Overdraft Facility ";
      balance=balance+withdraw;
      }
      else
      cout<<" After Withdrawl your Balance revels : "<<balance;
     }
};

class CSavingsAccount : public CBankAccount
{
staticfloat savbal;
public:
     void disp_savbal()
    {
      cout<<" Balance :- "<<savbal;
    }
    void deposit_savbal()
    {
      float deposit,interest;
      cout<<" Enter amount to Deposit :- ";
      cin>>deposit;
      savbal = savbal + deposit;
      interest=(savbal*2)/100;
      savbal=savbal+interest;
    }
    void withdraw_savbal()
    {
      float withdraw;
      cout<<" Balance :- "<<savbal;
      cout<<" Enter amount to be withdraw :-";
      cin>>withdraw;
      savbal=savbal-withdraw;
      if(withdraw > savbal)
      {
      cout<<" You have to take permission for Bank Overdraft Facility ";
      savbal=savbal+withdraw;
      }
      else
      cout<<" After Withdrawl your Balance revels : "<<savbal;
     }
};


float CCheckingAccount :: balance;
float CSavingsAccount :: savbal;


void main()
{
clrscr();
CCheckingAccount c1;
CSavingsAccount s1;

cout<<" Enter S for saving customer and C for current a/c customer ";
char type;
cin>>type;

int choice;

   if(type=='s' || type=='S')
     {
       s1.get_accinfo();
       while(1)
       {
     clrscr();
     cout<<" Choose Your Choice ";
     cout<<"1)   Deposit ";
     cout<<"2)   Withdraw ";
     cout<<"3)   Display Balance ";
     cout<<"4)   Display with full Details ";
     cout<<"5)   Exit ";
     cout<<"6)   Choose Your choice:-";
     cin>>choice;
     switch(choice)
     {
       case 1 : s1.deposit_savbal();
            getch();
            break;
       case 2 : s1.withdraw_savbal();
            getch();
            break;
       case 3 : s1.disp_savbal();
            getch();
            break;
       case 4 : s1.display_accinfo();
            s1.disp_savbal();
            getch();
            break;
       case 5 : goto end;
       default: cout<<" Entered choice is invalid,"TRY AGAIN"";
     }
       }
     }
    else
     {
       {
       c1.get_accinfo();
       while(1)
       {
     cout<<" Choose Your Choice ";
     cout<<"1)   Deposit ";
     cout<<"2)   Withdraw ";
     cout<<"3)   Display Balance ";
     cout<<"4)   Display with full Details ";
     cout<<"5)   Exit ";
     cout<<"6)   Choose Your choice:-";
     cin>>choice;
     switch(choice)
     {
       case 1 : c1.deposit_currbal();
            getch();
            break;
       case 2 : c1.withdraw_currbal();
            getch();
            break;
       case 3 : c1.disp_currbal();
            getch();
            break;
       case 4 : c1.display_accinfo();
            c1.disp_currbal();
            getch();
            break;
       case 5 : goto end;
       default: cout<<" Entered choice is invalid,"TRY AGAIN"";
     }
       }
     }
end:
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote