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

This project is to be done in C++ Design a generic class to hold the following i

ID: 3718198 • Letter: T

Question

This project is to be done in C++

Design a generic class to hold the following information about a bank account: Balance . Number of deposits this month Number of withdrawals Annual interest rate The class should have the following member functions Constructor: accept arguments for balance and interest rate deposit: a virtual function that accepts an argument for the amount of the deposit withdrawal: a virtual function that accepts an argument for the amount of the withdrawal calclnt: a virtual function that updates the balance by calculating the monthly interest earned by the account, and adding this interest into the balance . Next, design a savings account class; derived from the generic account class, the savings account class should have the following members status (to represent an active or inactive account) If the balance of a savings account falls below $25, it becomes inactive. (The status member could be a flag variable.) No more withdrawals may be made until the balance is raised above $25, at which time the account becomes active again. The savings account class should have the following member functions withdraw: A function that checks to see if the account is inactive before a withdrawal is made. (No withdrawal will be allowed if the account is not active) a withdrawal is then made by calling the base class version of the function. .Deposit: a function that checks to see if the account is inactive before a deposit is made. If the account is inactive and then deposit brings the balance above $25, the account becomes active again. The deposit is then made by calling the base class version of the function.

Explanation / Answer

Answer:-

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

class account
{
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 cur_acct : public account
{
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 sav_acct : public account
{
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 cur_acct :: balance;
float sav_acct :: savbal;


void main()
{
clrscr();
cur_acct c1;
sav_acct 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:
}
}

2 nd approach:

#include <iostream>
#include <string>
using namespace std;

class Account{
   private:
       string firstname;
       string lastname;
       string FullName;
       int accountnumber;
       double balance;
   public:
       Account(){
           firstname = "Raaj";
           lastname = "Lokanathan";
           FullName = "Raaj Lokanathan";
           accountnumber = 5671;
           balance = 0.0;
       }
       Account(string fName,string lName,int accno,double bal);
       void setFullName(string fullname);
       void setaccountnumber(int accno);
       void setbalance(double bal);
       void setwithdraw(int wdraw);
       void setdeposit(int dep);
       string getFullName();
       int getaccountnumber();
       double getbalance();
       void display();

};

Account::Account(string fName,string lName,int accno,double bal){
   firstname = fName;
   lastname = lName;
   accountnumber = accno;
   balance = bal;
}

void Account::setFullName(string fullname){
   FullName = fullname;
}

void Account::setaccountnumber(int accno){
   accountnumber = accno;
}

void Account::setbalance(double bal){
   balance = bal;
}

void Account::setwithdraw(int wdraw){
   wdraw=balance-wdraw;
}

void Account::setdeposit(int dep){
   dep=dep+balance;
}

string Account::getFullName(){
   return FullName;
}

int Account::getaccountnumber(){
   return accountnumber;
}

double Account::getbalance(){
   return balance;
}

void Account::display(){
   cout<<"First Name: "<<firstname<<endl;
   cout<<"Last Name: "<<lastname<<endl;
   cout<<"Account Number: "<<accountnumber<<endl;
   cout<<"Current Balance: "<<balance<<endl;
}

int main(){
   Account Acc;
   Acc.setFullName("Raaj Lokanathan");
   Acc.setaccountnumber(5671);
   Acc.setbalance(0.0);
   Acc.display();
   Account acc[50];
   string full_name;
   int acc_no;
   double bAl;
   int i;
   for(i=0;i<50;i++){
       cout<<"Please enter the details for the customer: "<<i+1<<endl;
       cout<<"Please enter your full name: ";
       getline(cin,full_name);
       cout<<"Please enter your account number: ";
       cin>>acc_no;
       cout<<"Please enter your current balance: ";
       cin>>bAl;
       acc[i].setFullName(full_name);
       acc[i].setaccountnumber(acc_no);
       acc[i].setbalance(bAl);
   }
   for(i=0;i<50;i++){
       cout<<"Detail for the bank customers"<<i+1<<endl;
       acc[i].display();
   }

   system("pause");

   return 0;

}

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