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 11:30
One subtask in the game is to roll the dice. explain why is roll the dice an abstraction.
Answers: 3
question
Computers and Technology, 22.06.2019 14:30
Complete the sentence based on your knowledge of the professional difficulties faced by music artists. digital technology allows audiences to see free live telecasts of music or dance performances through
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
How do you write an argumentative essay about the importance of free enterprise ?
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
Which finger presses the h key on the keyboard? index finger on the left hand pinky finger on the right hand index finger on the right hand thumb on the left hand
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
Mathematics, 22.01.2021 01:00
question
Mathematics, 22.01.2021 01:00
question
English, 22.01.2021 01:00
question
History, 22.01.2021 01:00
Questions on the website: 13722367