subject

Print person1's kids, apply the IncNumKids() function, and print again, outputting text as below. End each line with newline. Sample output for below program: Kids: 3 New baby, kids now: 4

#include
using namespace std;

class PersonInfo {
public:
void SetNumKids(int personsKids);
void IncNumKids();
int GetNumKids() const;
private:
int numKids;
};

void PersonInfo::SetNumKids(int personsKids) {
numKids = personsKids;
return;
}

void PersonInfo::IncNumKids() {
numKids = numKids + 1;
return;
}

int PersonInfo::GetNumKids() const {
return numKids;
}

int main() {
PersonInfo person1;

person1.SetNumKids(3);

this->numKids = numKids;
return 0;
}

2) Define the missing function. licenseNum is created as: (100000 * customID) + licenseYear. Sample output:

Dog license: 77702014
#include
using namespace std;

class DogLicense{
public:
void SetYear(int yearRegistered);
void CreateLicenseNum(int customID);
int GetLicenseNum() const;
private:
int licenseYear;
int licenseNum;
};

void DogLicense::SetYear(int yearRegistered) {
licenseYear = yearRegistered;
return;
}

// FIXME: Write CreateLicenseNum()

/* Your solution goes here */

int DogLicense::GetLicenseNum() const {
return licenseNum;
}

int main() {
DogLicense dog1;

dog1.SetYear(2014);
dog1.CreateLicenseNum(777);
cout << "Dog license: " << dog1.GetLicenseNum() << endl;

return 0;
}

3) Define a constructor as indicated. Sample output for below program:

Year: 0, VIN: -1
Year: 2009, VIN: 444555666
#include
using namespace std;

class CarRecord {
public:
void SetYearMade(int originalYear);
void SetVehicleIdNum(int vehIdNum);
void Print() const;
CarRecord();
private:
int yearMade;
int vehicleIdNum;
};

// FIXME: Write constructor, initialize year to 0, vehicle ID num to -1.

/* Your solution goes here */

void CarRecord::SetYearMade(int originalYear) {
yearMade = originalYear;
return;
}

void CarRecord::SetVehicleIdNum(int vehIdNum) {
vehicleIdNum = vehIdNum;
return;
}

void CarRecord::Print() const {
cout << "Year: " << yearMade << ", VIN: " << vehicleIdNum << endl;
return;
}

int main() {
CarRecord familyCar;

familyCar. Print();
familyCar. SetYearMade(2009);
familyCar. SetVehicleIdNum(444555666);
familyCar. Print();

return 0;
}

4) Write a second constructor as indicated. Sample output:

User1: Minutes: 0, Messages: 0
User2: Minutes: 1000, Messages: 5000
#include
using namespace std;

class PhonePlan{
public:
PhonePlan();
PhonePlan(int numMinutes, int numMessages);
void Print() const;
private:
int freeMinutes;
int freeMessages;
};

PhonePlan::PhonePlan() { // Default constructor
freeMinutes = 0;
freeMessages = 0;
return;
}

// FIXME: Create a second constructor with numMinutes and numMessages parameters.

/* Your solution goes here */

void PhonePlan::Print() const {
cout << "Minutes: " << freeMinutes << ", Messages: " << freeMessages << endl;
return;
}

int main() {
PhonePlan user1Plan; // Calls default constructor
PhonePlan user2Plan(1000, 5000); // Calls newly-created constructor

cout << "User1: ";
user1Plan. Print();

cout << "User2: ";
user2Plan. Print();

return 0;
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:50
Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. thus your code should put 11 + 22 + 33 + + 4949 + 50*50 into total. use no variables other than k and total.
Answers: 2
question
Computers and Technology, 23.06.2019 23:30
A. in packet tracer, only the server-pt device can act as a server. desktop or laptop pcs cannot act as a server. based on your studies so far, explain the client-server model.
Answers: 2
question
Computers and Technology, 24.06.2019 00:00
Consider the series where in this problem you must attempt to use the ratio test to decide whether the series converges. compute enter the numerical value of the limit l if it converges, inf if it diverges to infinity, minf if it diverges to negative infinity, or div if it diverges but not to infinity or negative infinity.
Answers: 1
question
Computers and Technology, 24.06.2019 09:00
Why might you chose to crest a function resume
Answers: 1
You know the right answer?
Print person1's kids, apply the IncNumKids() function, and print again, outputting text as below. En...
Questions
question
Spanish, 09.12.2021 03:50
question
Spanish, 09.12.2021 03:50
Questions on the website: 13722361