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

IN C++ PLEASE: Design a class named PersonData with the following member variabl

ID: 3885354 • Letter: I

Question

IN C++ PLEASE:

Design a class named PersonData with the following member variables:

• lastName

• firstName

• address

• city

• state

• zip

• phone

Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData, which is derived from the PersonData class. The CustomerData class should have the following member variables:

• customerNumber

• mailingList

The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool. It will be set to true if the customer wishes to be on a mailing list, or false if the customer does not wish to be on a mailing list. Write appropriate accessor and mutator functions for these member variables. Create a program that does the following: Create a function enterNCustomers(int n) that asks to enter n number customers. All the customer fields must be filled in, and the result of the function is a vector containing n customer objects. Note that you may read customer info in from a text file – it’s up to you. User input or input from a file. Create another function that displays all the customer information to the console.

Explanation / Answer

#include<iostream>
#include<string>

using namespace std;

class PersonData {
   private:
       string firstName;
       string lastName;
       string address;
       string city;
       string state;
       string zip;
       string phone;
   public:
       void setFname(string a){
           firstName = a;
       }
       void setLname(string a){
           lastName = a;
       }
       void setAddress(string a){
           address = a;
       }
       void setCity(string a){
           city = a;
       }

       void setState(string a){
           state = a;
       }
       void setZip(string a){
           zip = a;
       }
       void setPhone(string a){
           phone = a;
       }
       string getFname(){
           return firstName;
       }
       string getLname(string a){
           return lastName;
       }
       string getAddress(){
           return address;
       }
       string getCity(){
           return city;
       }

       string getState(){
           return state;
       }
       string getZip(string a){
           return zip;
       }
       string getPhone(){
           return phone;
       }
        void disp(){

            cout << firstName << endl;
            cout << lastName << endl;
            cout << address << endl;
            cout << city << endl;
            cout << state << endl;
            cout << zip << endl;
        }

};

class CustomerData : public PersonData
{
    private:
        int customerNumber;
        bool mailingList;
    public:
        void setCustomerNumber(int a){
             customerNumber = a;  
        }
        void setMailingList(bool a){
             mailingList = a;  
        }
        int getCustomerNumber(){
             return customerNumber;  
        }
        bool getMailingList(){
             return mailingList;  
        }
        void disp(){
            cout << customerNumber << endl;
            PersonData::disp();
            if (mailingList)
               cout << "True" << endl;
            else
               cout << "False" << endl;
        }
};

int main(){

   string input;
   int num,n;

   cout << "Enter number of customers :" << endl;
   cin >> n;
   CustomerData *ct = new CustomerData[n];


   for (int i = 0; i<n; i++){
       ct[i].setCustomerNumber(i);
       cout << "Enter first name : ";
       cin >> input;
       ct[i].setFname(input);
       cout << "Enter last name : ";
       cin >> input;
       ct[i].setLname(input);
       cout << "Enter address : ";
       cin >> input;
       ct[i].setAddress(input);
       cout << "Enter city : ";
       cin >> input;
       ct[i].setCity(input);
       cout << "Enter state : ";
       cin >> input;
       ct[i].setState(input);
       cout << "Enter zip : ";
       cin >> input;
       ct[i].setZip(input);
       cout << "Enter phone : ";
       cin >> input;
       ct[i].setPhone(input);
       cout << "Enter Mailing list option (1-True/0-False) : ";
       cin >> num;
       if (num == 0)
          ct[i].setMailingList(false);
       else
          ct[i].setMailingList(true);


   }
   for (int i = 0; i<n; i++)
       ct[i].disp();

   return 0;
}