How to Define the Missing Function in a Dog License Number Program?

  • C/C++
  • Thread starter ineedhelpnow
  • Start date
In summary, the missing function is called "CreateLicenseNum" and it is responsible for calculating the license number for a dog. The function should be renamed to "SetYear" because it already exists and it is responsible for setting the year for the license.
  • #1
ineedhelpnow
651
0
i have another question i need help with :eek:
Define the missing function. licenseNumber is created as: (100000 * customID) + licenseYear. Sample output:

Dog license: 77702014
Sample program:
Code:
#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()
<STUDENT CODE> 

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

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

   return 0;
}

Below, do not type an entire program. Only type the portion indicated by the above instructions (and if a sample program is shown above, only type the <STUDENT CODE> portion.)

normally if i look at something long enough I am able to figure it out but this one just isn't clicking. how do i do it? :confused:
 
Technology news on Phys.org
  • #2
ineedhelpnow said:
normally if i look at something long enough I am able to figure it out but this one just isn't clicking. how do i do it? :confused:

Hey! (Smile)

For CreateLicenseNum() we need to the same thing as is already there for SetYear().
But instead of simply copying the parameter, we need to calculate with the given formula what to store. (Thinking)
 
  • #3
:confused: so something like this?
Code:
void DogLicense::CreateLicenseNum(int licenseNumber) {
   licenseNumber =  (100000 * customID) + licenseYear;
   return;
}
 
  • #4
ineedhelpnow said:
:confused: so something like this?
Code:
void DogLicense::CreateLicenseNum(int licenseNumber) {
   licenseNumber =  (100000 * customID) + licenseYear;
   return;
}

Yep. Something like that. (Smile)
It's just that the parameter should be customID instead.
Just like it says in the class definition.
Otherwise it won't compile. (Worried)
 
  • #5
you mean like this
Code:
void DogLicense::CreateLicenseNum(int customID) {
  int licenseNumber =  (100000 * customID) + licenseYear;
   return;
}
 
  • #6
ineedhelpnow said:
you mean like this
Code:
void DogLicense::CreateLicenseNum(int customID) {
  int licenseNumber =  (100000 * customID) + licenseYear;
   return;
}

Yep. (Smile)

Except that you've introduced an 'int' that shouldn't be there.
 
  • #7
but if i don't put int i get the message that 'licenseNumber’ was not declared in this scope. don't i have to use int to introduce the variable?
 
  • #8
ineedhelpnow said:
but if i don't put int i get the message that 'licenseNumber’ was not declared in this scope. don't i have to use int to introduce the variable?

The class contains a data member named [m]licenseNum[/m], which is the one that needs to be initialized.
Perhaps you can change 'licenseNumber' into 'licenseNum'? (Wondering)
 
  • #9
it finally worked!
Code:
void DogLicense::CreateLicenseNum(int customID) {
  licenseNum =  (100000 * customID) + licenseYear;
   return;
}

blowing-kiss-thank-you-smiley-emoticon.gif
 

FAQ: How to Define the Missing Function in a Dog License Number Program?

What is a dog license number?

A dog license number is a unique identification number assigned to a dog by the government or local animal control agency. It serves as a way to track and identify dogs, and also provides proof that the dog has been vaccinated against rabies.

How do I get a dog license number?

The process for obtaining a dog license number may vary depending on your location. In most cases, you can apply for a dog license through your local animal control agency or online through your city or county's website. You will need to provide proof of your dog's rabies vaccination and pay a fee.

Do I need a dog license number?

In most places, it is required by law to license your dog. This helps to ensure that all dogs in the community are vaccinated against rabies and can be returned to their owners if they are lost. Additionally, having a dog license number can save you from potential fines or penalties.

Can I transfer my dog's license number if I move to a new location?

In most cases, a dog license number is only valid in the location where it was issued. If you move to a new area, you will need to apply for a new dog license in that location. However, some states have reciprocal agreements, allowing for the transfer of a dog license between certain locations.

What should I do if I lose my dog's license number?

If you lose your dog's license number, you can contact your local animal control agency to request a replacement. They may require you to provide proof of your dog's rabies vaccination again. It is important to keep your dog's license number in a safe place in case it is needed for any reason.

Back
Top