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

C++ Help. Write a program that maintains loan information for a local bank. Crea

ID: 3834192 • Letter: C

Question

C++ Help. Write a program that maintains loan information for a local bank. Create a base class Loan which has the following members: Data members: string name, int loanNumber, double loanAmount Member functions: Loan(); //default constructor Loan(string,int,double); //initialization constructor ~Loan(); //destructor // getter for each data member or one function getData() to return all data members (through passing by reference) // setter for each data member or one function setData() to set all data members void print() const; //display the loan info Create 2 derived classes, HomeLoan and AutoLoan. HomeLoan has detail info about Loan such as address, city, state and zipCode which are all string types. AutoLoan has details about the auto such as maker(string) yearBuilt (int) and model(string). Both derived classes have a print() method to display their own information. Add constructors, destructor, setter/getter for each derived class (You can use setAddress() to set all the location information, setAutoInfo() to set all the car info, etc.) Create instance for each Derived Class and test all the functionality. Display information for each type of the loan.

Explanation / Answer

Answer->

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

class Loan
{
  
public:
   int loanNumber;
   double loanAmount;
char name[20];
public:
  
Loan();
Loan(char *s,int n ,double a ); // This is the constructor
  
void setData(char *s,int n ,double a );
int getLoanNumber();
double getLoanAmount();
char* getName();
  

};

Loan::Loan(char *s,int n ,double a )
{
loanNumber=n;
loanAmount=a;
strcpy(name,s);
}
void Loan::setData(char *s,int n ,double a )
{
loanNumber=n;
loanAmount=a;
strcpy(name,s);
}
int Loan::getLoanNumber()
{
return loanNumber;
}
double Loan::getLoanAmount()
{
return loanAmount;
}
char* Loan::getName()
{
return name;
}
Loan::Loan()
{
}
class HomeLoan: public Loan
{
public:
   char address[20];
   char city[20];
   char state[20];
   char zipCode[20];
   public:
   HomeLoan();
   HomeLoan(char *a ,char *c,char *s,char *z);
void setAddress(char *a ,char *c,char *s,char *z);
char* getAddress();
char* getCity();
char* getState();
char* getZipCode();
void print();
  
};
HomeLoan::HomeLoan(char *a ,char *c,char *s,char *z)
   {
   strcpy(address,a);
   strcpy(city,c);
   strcpy(state,s);
   strcpy(zipCode,z);
   }
void HomeLoan::setAddress( char *a ,char *c,char *s,char *z)
   {
   strcpy(address,a);
   strcpy(city,c);
   strcpy(state,s);
   strcpy(zipCode,z);
   }
char* HomeLoan::getAddress()
{
return address;
}
char* HomeLoan::getCity()
{
return city;
}
char* HomeLoan::getState()
{
return state;
}
char* HomeLoan::getZipCode()
{
return zipCode;
}
void HomeLoan::print()
{
cout<<"HomeLoan Details : "<<endl;
cout<<"Address-"<<address<<endl;
cout<<"City-"<<city<<endl;
cout<<"State-"<<state<<endl;
cout<<"ZipCode-"<<zipCode<<endl;
}
class AutoLoan: public Loan
{
public:
    char maker[20];
   int year;
char model[20];
public:
   AutoLoan();
   AutoLoan(char *m ,int y,char *o);
   void setAutoInfo(char *m ,int y,char *o);
   char* getMaker();
   int getYear();
   char* getModel();
   void print();
};
AutoLoan::AutoLoan(char *m ,int y,char *o)
{
strcpy(maker,m);
year=y;
strcpy(model,o);
}
void AutoLoan::setAutoInfo(char *m ,int y,char *o)
{
strcpy(maker,m);
year=y;
strcpy(model,o);
}
char* AutoLoan::getMaker()
{
return maker;
}
char* AutoLoan::getModel()
{
return model;
}
int AutoLoan::getYear()
{
return year;
}
void AutoLoan::print()
{
cout<<" AutoLoan Details : "<<endl;
cout<<"maker-"<<maker<<endl;
cout<<"year-"<<year<<endl;
cout<<"model-"<<model<<endl;
}
int main() {
   HomeLoan h("44gh","yuff","ert","657hg");
   AutoLoan a("ghg",2010,"fkj");
   h.print();
   a.print();
   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