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, 23.06.2019 13:30
Select the correct answer from each drop-down menu. which types of computer networks are bigger as well as smaller than a man? a man is a network of computers that covers an area bigger than a , but smaller than a .
Answers: 1
question
Computers and Technology, 24.06.2019 10:30
You're programming an infinite loop. what must you include in your code to prevent crashes? in roblox
Answers: 2
question
Computers and Technology, 24.06.2019 15:00
Universal windows platform is designed for which windows 10 version?
Answers: 1
question
Computers and Technology, 25.06.2019 09:20
Part d: float check string has a method s.isdigit() that returns true if string s contains only digits and false otherwise, i.e. s is a string that represents an integer. write a function named float_check that takes one parameter that is a string and returns true if the string represents a float and false otherwise. for the purpose of this function we define a float to be a string of digits that has at most one decimal point. note that under this definition an integer argument will return true. remember “edge cases” such as “45.” or “.45”; both should return true. for example: float_check('1234') returns true float_check('123.45') returns true float_check('123.45.67') returns false float_check('34e46') returns false float_check('.45') returns true float_check('45.') returns true float_check('45..') returns false
Answers: 2
You know the right answer?
Print person1's kids, apply the IncNumKids() function, and print again, outputting text as below. En...
Questions
question
Social Studies, 16.09.2019 22:50
Questions on the website: 13722362