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

1. Using C++, write and test a class called CreditReport. This class represents

ID: 3671213 • Letter: 1

Question

1. Using C++, write and test a class called CreditReport. This class represents a real-world credit report. In this problem we will model the credit report in the following way. It should contain a credit score (ranges 330 – 830), a debt profile (total real estate and credit card debt), account types (number of real estate, credit cards, and retail cards), length of history (oldest account age and average account age), and number of hard inquiries (number of times your credit report has been accessed) as attributes. Operations that may be applied to your CreditReport include: printReport and updateReport (you may refine updateReport for use with individual class attributes). Be sure to include all necessary getters and setters, constructors, and destructors. Be sure to define a copy constructor! Write an application which instantiates three credit reports. These include Experian, TransUnion, and Equifax. Your application should decrease credit scores as the credit limit on cards is approached and increase scores as the credit is paid off. Also the older the credit accounts, the higher the credit score. Also, use the other attributes of the CreditReport as you see fit.

Explanation / Answer

//Program

#include <iostream>

using namespace std;

class CreditReport
{
/*a credit score (ranges 330 – 830)*/
int creditScore;
/*a debt profile (total real estate and credit card debt)*/
double debtProfile;
/*account types (number of real estate, credit cards, and retail cards)*/
string accountType;
/*length of history (oldest account age and average account age)*/
int lengthOfHistory;
/*number of hard inquiries (number of times your credit report has been accessed)*/  
int numOfHardInquiries;

public:
    /* constructor*/
    CreditReport(int c, double d,string a,int len, int h)
   {
      numOfHardInquiries=h;
      lengthOfHistory=len;
      accountType=a;
      debtProfile=d;
      creditScore=c;
   }
    //copy constructor
    CreditReport(const CreditReport &C2)
    {
        numOfHardInquiries=C2.numOfHardInquiries;
      lengthOfHistory=C2.lengthOfHistory;
      accountType=C2.accountType;
      debtProfile=C2.debtProfile;
      creditScore=C2.creditScore;
   }
    /*destructor*/
    ~CreditReport(){
   }
    /*to print Report */

   void printReport()
    {
        cout<<endl<<"Credit Score: "<<creditScore;
        cout<<endl<<"Debt Profile: "<<debtProfile;
        cout<<endl<<"Account Type: "<<accountType;
        cout<<endl<<"Length of the History: "<<lengthOfHistory;
        cout<<endl<<"Number of Hard Inquiries: "<<numOfHardInquiries;
   }
   /* updateReport (you may refine updateReport for use with individual class attributes).*/
   void updateReport()
    {
       
   }
   /* Be sure to include all necessary getters and setters*/
   int getNumOfHardInquiries()
   {
       return numOfHardInquiries;
   }
  
   void setNumOfHardInquiries(int h)
   {
       numOfHardInquiries=h;
   }
   int getLengthOfHistory()
   {
       return lengthOfHistory;
   }
  
   void setLengthOfHistory(int len)
   {
       lengthOfHistory=len;
   }
   string getAccountType()
   {
       return accountType;
   }
  
   void setAccountType(string a)
   {
       accountType=a;
   }
   double getDebtProfile()
   {
       return debtProfile;
   }
  
   void setDebtProfile(double d)
   {
       debtProfile=d;
   }
   int getCreditScore()
   {
       return creditScore;
   }
  
   void setCreditScore(int c)
   {
       creditScore=c;
   }
};


/*Write an application which instantiates three credit reports. These include Experian, TransUnion, and Equifax.*/
int main()
{
   CreditReport Experian(350,3450,"creditCard",12,20);
   CreditReport TransUnion(800,5000,"retailcard",2,5);
   CreditReport Equifax(500,3000,"retailcard",22,50);
   CreditReport C2 = Experian; // to call Copy constructor
   cout<<endl<<"Experian report";
   C2.printReport();
  
   cout<<endl<<"TransUnion report";
   TransUnion.printReport();
  
   cout<<endl<<"Equifax report";
   Equifax.printReport();
}