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

$$ I need a c++ visual studio help please. Customer Data. This program will have

ID: 3845569 • Letter: #

Question

$$ I need a c++ visual studio help please.

Customer Data. This program will have two classes. The first class defines a person, which means this class can be used for anything that involves a person. We will use it to define a Customer but it could be used to define a Student.

Create a class called PersonData and it will have its class declaration in PersonData.h and its implementation in PersonData.cpp. This class will have private data member’s lastName, firstName, address, city, state, zip and phone number as strings. Write the appropriate accessor and mutator functions for these member variables. It should have two constructors. One constructor is a default constructor that sets all of the data members to empty strings. A second constructor has parameters for all of its data members.

Create a class called CustomerData which will have its class declaration in CustomerData.h and its implementation in CustomerData.cpp. This class will be a derived class of PersonData. This class will have two private data members for the customer number (customerNumber) as an integer; the other will be called mailingList which is a bool to indicate if they want to be on the mailing list or not. Write appropriate accessor and mutator functions for these data members. This class will also have two constructors. It will have a default constructor that sets its data members to zero and false. The other constructor will have parameters to set all of the data members of the two classes.

Create a program that will create two instances of the CustomerData class. It must create one instance using the default constructor and then another using the second constructor. Once both instances are fully populated with data, call a function that will display the customer information.

void displayCustomer(CustomerData c)

Explanation / Answer

#include"stdafx.h"

#include<iostream>

#include<string>

#include "CustomerData.h"

using namespace std;

//main method

int main(int argc, char** argv)

{

     //declare variables

     string lastNm;

     string firstNm;

     string address;

     string city;

     string state;

     string phone;

     string zip;

     bool mailList;

     //prompt and read the details information

     cout << "Enter the Last name: ";

     cin >> lastNm;

     cout << "Enter the First name: ";

     cin >> firstNm;

     cin.ignore();

     cout << "Enter the Address: ";

     getline(cin, address);

     cout << "Enter the City: ";

     getline(cin, city);

     cout << "State: ";

     cin >> state;

     cout << "Enter the Phone Number: ";

     cin >> phone;

     cout << "Enter the ZIP code: ";

     cin >> zip;

cout << "Mailing list(0 for false,otherwise it is for true): ";

     cin >> mailList;

     //Test the object

CustomerData c(lastNm, firstNm, address, city, state, zip, phone, mailList);

     //call the display method

     c.displayCustomer(c);

     system("pause");

     return 0;

}

PersonData.cpp

//header files

#include"stdafx.h"

#include <iostream>

#include<string>

using namespace std;

#include "PersonData.h"

//Constructor

PersonData::PersonData(string ln, string fn, string a, string c, string s, string z, string p)

{

     lastNm = ln;

     firstNm = fn;

     address = a;

     city = c;

     state = s;

     phone = p;

     zip = z;

}

//print the information

void PersonData::pntInfo() const

{

     cout << "Personal Information: " << endl;

     cout << "Last name: " << lastNm << endl;

     cout << "First name: " << firstNm << endl;

     cout << "Address: " << address << endl;

     cout << "City: " << city << endl;

     cout << "State: " << state << endl;

     cout << "ZIP: " << zip << endl;

     cout << "Phone: " << phone << endl;

}

PersonData.h

//header files

#include"stdafx.h"

#include<string>

#ifndef PERSONDATA_H

#define PERSONDATA_H

//class declaration

class PersonData

{

     protected:

          string lastNm;//last name

          string firstNm;//first name

          string address;

          string city;

          string state;

          string phone;

          string zip;

     public:

          //Default constructor

          PersonData()

          {

              lastNm = firstNm = address = city = state = phone = zip = "";

          }

          //Constructor

          PersonData(string, string, string, string, string, string, string);

          //mutator methods

          void setLN(string ln)

          {

              lastNm = ln;

          }

          void setFN(string fn)

          {

              firstNm = fn;

          }

          void setAddr(string a)

          {

              address = a;

          }

          void setCity(string c)

          {

              city = c;

          }

          void setStat(string s)

          {

              state = s;

          }

          void setPhon(string p)

          {

              phone = p;

          }

          void setZip(string z)

          {

              zip = z;

          }

          //accessor methods

          string getLN() const

          {

              return lastNm;

          }

          string getFN() const

          {

              return firstNm;

          }

          string getAddr() const

          {

              return address;

          }

          string getCity() const

          {

              return city;

          }

          string getStat() const

          {

              return state;

          }

          string getPhon() const

          {

              return phone;

          }

          string getZip() const

          {

              return zip;

          }

          //print the information

          void pntInfo() const;

};

#endif   /* PERSONALDATA_H */

CustomerData.cpp

//header files

#include"stdafx.h"

#include<string>

#include<iostream>

using namespace std;

#include "CustomerData.h"

//implement the displayCustomer() method

void CustomerData::displayCustomer(CustomerData c) const

{

     cout << endl << "Personal Information: " << endl;

     cout << "Last name: " << lastNm << endl;

     cout << "First name: " << firstNm << endl;

     cout << "Address: " << address << endl;

     cout << "City: " << city << endl;

     cout << "State: " << state << endl;

     cout << "ZIP: " << zip << endl;

     cout << "Phone: " << phone << endl;

     cout << "Customer Number: #" << Customernum << endl;

     cout << "Mailing List: " << mailList << endl;

}

CustomerData.h

//header files

#include"stdafx.h"

#ifndef CUSTOMERDATA_H

#define   CUSTOMERDATA_H

#include <iostream>

using namespace std;

#include "PersonData.h"

//class declaration

class CustomerData :public PersonData

{

     //declare data members

private:

     //customer number

     int Customernum;

     //mailing list

     bool mailList;

public:

     //default constructor

     CustomerData() :PersonData()

     {

          Customernum = rand() % 9000 + 1000;

          mailList = false;

     }

     //constructor

CustomerData(string ln, string fn, string a, string c, string s, string z, string p, bool m) :PersonData(ln, fn, a, c, s, z, p) {

          Customernum = rand() % 9000 + 1000;

          mailList = m;

     }

     //set mailing list

     void setMail(bool m)

     {

          mailList = m;

     }

     //get customer number

     int getNum() const

     {

          return Customernum;

     }

     //get mailing list

     bool getMail() const

     {

          return mailList;

     }

     //print the information

     void displayCustomer(CustomerData c) const;

};

#endif   /* CUSTOMERDATA_H */