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

Scroll down to the bottom to see my problem. My second customer seems like it is

ID: 3549342 • Letter: S

Question

Scroll down to the bottom to see my problem. My second customer seems like it is off by one? Look for bold

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

// Display customer information
void displayCustomer(CustomerData, CustomerData);

void main()
{
int num; // To hold customer nunmber;
string lname; // To hold last name
string fname; // To hold first name
string addy; // To hold address
string city; // To hold city
string state; // To hold state
string zip; // To hold zip code
string phone; // To hold phone
bool list; // To hold mailing list response
char choice; // To hold user choice (yes or no)

// Create a CustomerData object and use default
// constructor
CustomerData data;

// Get information from user
cout << "Enter your customer number: ";
cin >> num;
cin.get();
cout << "Enter your last name: ";
getline(cin, lname);
cout << "Enter your first name: ";
getline(cin, fname);
cout << "Enter your address: ";
getline(cin, addy);
cout << "Enter the city: ";
getline(cin, city);
cout << "Enter the state: ";
getline(cin, state);
cout << "Enter the zip code: ";
getline(cin, zip);
cout << "Enter your phone number without spaces: ";
getline(cin, phone);

// See if they want to be on the mailing list
cout << "Do you wish to be on the mailing list? ";
cout << "Enter Y for yes or N for no: ";
cin >> choice;

if (choice == 'Y' || choice == 'y')
{
list = true;
}
else
{
list = false;
}

cout << endl;

//// Store the info
data.setCustomerNumber(num);
data.setLastName(lname);
data.setFirstName(fname);
data.setAddress(addy);
data.setCity(city);
data.setState(state);
data.setZip(zip);
data.setPhoneNumber(phone);
data.setMailingList(list);

// Already filled in data
CustomerData c(2, "Williams", "Cameo", "3127 Heller",
"New York", "New York", "56478", "4524564568", false);

// Display the customer information calling the second constructor
displayCustomer(data, c);


}
//***********************************************
// displayCustomer function returns displays *
// The last name, first name, address, city, *
// state, zip code, and phone number *
// of the person *
//***********************************************
void displayCustomer(CustomerData data, CustomerData c)
{
cout << "CUSTOMER #" << data.getCustomerNumber() << endl;
cout << "___________" << endl;
cout << " Last Name: " << data.getLastName() << endl;
cout << " First Name: " << data.getFirstName() << endl;
cout << " Address: " << data.getAddress() << endl;
cout << " City: " << data.getCity() << endl;
cout << " State: " << data.getState() << endl;
cout << " ZIP: " << data.getZip() << endl;
cout << " PhoneNumber: " << data.getPhoneNumber() << endl;
cout << " Mailing List? ";

if(data.getMailingList())
{
cout << "Yes";
}
else
{
cout << "No";
}
cout << endl << endl;

cout << "CUSTOMER #" << c.getCustomerNumber() << endl;
cout << "___________" << endl;
cout << " Last Name: " << c.getLastName() << endl;
cout << " First Name: " << c.getFirstName() << endl;
cout << " Address: " << c.getAddress() << endl;
cout << " City: " << c.getCity() << endl;
cout << " State: " << c.getState() << endl;
cout << " ZIP: " << c.getZip() << endl;
cout << " PhoneNumber: " << c.getPhoneNumber() << endl;
cout << " Mailing List? ";

if(c.getMailingList())
{
cout << "Yes";
}
else
{
cout << "No";
}
cout << endl << endl;
}

// Here is the display can you tell me why the second customer

// displays like this...


Enter your customer number: 1
Enter your last name: Williams
Enter your first name: tory
Enter your address: taylor
Enter the city: oak
Enter the state: wa
Enter the zip code: 98277
Enter your phone number without spaces: 360
Do you wish to be on the mailing list?
Enter Y for yes or N for no: n

CUSTOMER #1
___________
Last Name: Williams
First Name: tory
Address: taylor
City: oak
State: wa
ZIP: 98277
PhoneNumber: 360
Mailing List? No

CUSTOMER #2
___________
Last Name: 4106789456 // This should be the phone number
First Name: Williams // Off by one Williams is the last name
Address: Cameo
City: 3127 Heller
State: New York
ZIP: New York
PhoneNumber: 56478
Mailing List? No

Press any key to continue . . .

Here are the customer classes .h and .cpp

#ifndef CUSTOMERDATA_H
#define CUSTOMERDATA_H
#include "PersonData.h"

class CustomerData : public PersonData
{
private:
int customerNumber; // To hold customer number
bool mailingList; // To include on mailing list or not

public:
// Default constructors
CustomerData();

// Constructors
CustomerData(int, string, string, string, string,
  string, string, string, bool);
  
// Mutator function to set customer number
void setCustomerNumber(int);

// Mutator function to set mailing list answer
void setMailingList(bool);

// Accessor function to get customer number
int getCustomerNumber();

// Accessor function to get mailing list response
bool getMailingList();

};
#endif

// Customer.cpp
// Implementation file for the CustomerData class
#include "CustomerData.h"
#include <iostream>
using namespace std;

//***********************************************
// Default constructors set customerNumber to 0 *
// and mailingList to false                     *
//***********************************************
CustomerData::CustomerData() : PersonData()
{ customerNumber = 0;
  mailingList = false; }


//***********************************************
// Constructor that sets the data members of    *
// both classes                                 *
//***********************************************
CustomerData::CustomerData(int num, string f,
string a, string c, string s, string z, string p,
string l, bool mail) : PersonData(l, f, a, c, s, z, p)
{
customerNumber = num;
mailingList = mail;
}

//***********************************************
// setCustomerNumber function sets the customer *
// number                                       *
//***********************************************
void CustomerData::setCustomerNumber(int num)
{
customerNumber = num;
}

//***********************************************
// setMailingList function sets the response to *
// if the customer wants to be on the mailing   *
// list or not                                  *
//***********************************************
void CustomerData::setMailingList(bool mail)
{
mailingList = mail;
}

//***********************************************
// getCustomerNumber function returns the       *
// customer number                              *
//***********************************************
int CustomerData::getCustomerNumber()
{
return customerNumber;
}

//***********************************************
// getMailingList returns if the customer wants *
// to be on the mailing list or not             *
//***********************************************
bool CustomerData::getMailingList()
{
return mailingList;
}

Explanation / Answer

//THE WAY YOU ARE ASSIGNING / CALLING IN CONSTUCTOR IS WRONG.
// PLEASE CHANGE CustomerData arugment constructor as follows.
// LOOK FOR BOLD ONE FOR FIXED CODE.
// STILL YOU FACE ANY ISSUE, PLEASE COMMENT HERE

// Implementation file for the CustomerData class
#include "CustomerData.h"
#include <iostream>
using namespace std;

//***********************************************
// Default constructors set customerNumber to 0 *
// and mailingList to false *
//***********************************************
CustomerData::CustomerData() : PersonData()
{ customerNumber = 0;
mailingList = false; }


//***********************************************
// Constructor that sets the data members of *
// both classes *
//***********************************************
CustomerData::CustomerData(int num, string l,
string f, string a, string c, string s, string z,
string p, bool mail) : PersonData(l, f, a, c, s, z, p)
{
customerNumber = num;
mailingList = mail;
}

//***********************************************
// setCustomerNumber function sets the customer *
// number *
//***********************************************
void CustomerData::setCustomerNumber(int num)
{
customerNumber = num;
}

//***********************************************
// setMailingList function sets the response to *
// if the customer wants to be on the mailing *
// list or not *
//***********************************************
void CustomerData::setMailingList(bool mail)
{
mailingList = mail;
}

//***********************************************
// getCustomerNumber function returns the *
// customer number *
//***********************************************
int CustomerData::getCustomerNumber()
{
return customerNumber;
}

//***********************************************
// getMailingList returns if the customer wants *
// to be on the mailing list or not *
//***********************************************
bool CustomerData::getMailingList()
{
return mailingList;
}

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