Dog age in human years (Dog Years)
To calculate the age of a dog in human terms, we need to use two different multipliers, A and B.
For each of the dog's first two years of life, multiply its age by multiplier A
For all years after the first two, multiply by B
The value of A and B depends on the size of the dog (and in real life, the breed too).
|Size of Dog
Here is what your program needs to do:
- Input the size of dog - limit possible entries to "large", "medium" or "small"
- Input the actual age of the dog in years
- Set multiplier values for A and B based on size
- Set a variable for age of dog up to two years
- Set a variable for age of dog above two years
- Calculate the human years for the first two years
- Add on the human years for the remaining age above two years
- Output the dog's real age and age in human years.
Test it with the following values:
Rover is a medium dog aged 5.5 years
2 * A = 21
6 * 3.5 = 21
Total = 42. Rover is 42 in dog years
Rex is a small dog aged 4 years
A = 12.5, B=5. Dog years = (12.5 * 2) + (5 * 2) = 35
Bella is a large dog aged 1.5 years.
A = 9, B=8. Dog years = 9 * 1.5 = 13.5