#include <iostream> using namespace std; class DogLicense{ public: void SetYear(
ID: 3797187 • Letter: #
Question
#include <iostream>
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;
}
Explanation / Answer
void DogLicense::CreateLicenseNum(int customID) {
licenseNum = customID*100000 + licenseYear ;
return;
}
Above code needs to be insereted.
First check in the declaration area the parameter to be passed, return type and exact name of the function. In the similar way, define the function. The formula is given in the description, so accordingly calculate.
So after inserting this code, program looks as below:
#include <iostream>
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 */
void DogLicense::CreateLicenseNum(int customID) {
licenseNum = customID*100000 + licenseYear ;
return;
}
int DogLicense::GetLicenseNum() const {
return licenseNum;
}
int main() {
DogLicense dog1;
dog1.SetYear(2014);
dog1.CreateLicenseNum(777);
cout << "Dog license: " << dog1.GetLicenseNum() << endl;
return 0;
}
And the Output is as below:
Dog license: 77702014
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.