In this challenge we are going to create a cat’s age convertor find out how old a cat is in “human years”. This is very useful to understand more about cats and the care they need and to find out at what stage of life a cat is.
To convert the age of a cat in human years you have to do the following:
- Year 1 counts for 15 Human Years
- Year 2 counts for 9 Human Years
- Thereafter each year counts for 4 Human Years
- A 1 year old cat is 15 Human Years old,
- A 2 years old cat is 15 + 9 = 24 Human Years old,
- A 3 years old cat is 15 + 9 + 4 = 28 Human Years old,
- A 4 years old cat is 15 + 9 + 4 + 4 = 32 Human Years old,
- A 5 years old cat is 15 + 9 + 4 + 4 + 4= 36 Human Years old,
- A 10 years old cat is 15 + 9 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 = 56 Human Years old.
You can check the full cat’s age conversion chart at the bottom of this post.
Complete the following code to ask the user to input the age of a cat in years and return the equivalent in human years.
Amend your code so that it also works for cats under 1 year old. In this case you will have to ask for the cat’s age in months and use the conversion chart below (At the bottom of this post) to return the cat’s age in human years.
The stages of life of a cat are as follows:
- Kitten – from birth to 6 months,
- Junior – from 7 months to 2 years,
- Prime – from 3 years to 6 years,
- Mature – from 7 years to 10 years,
- Senior – from 11 years to 14 years,
- Geriatic – from 15 years above.
Extend your code to tell the end-user what stage of life their cat’s age is corresponding to.
Create another program where the user enters their age in human years and the program tells the user how old they would be if they were a cat!
Cat’s age conversion chart:
|Life Stage||Cat years||Human years|
|Kitten||2 months||9 to 10 months|
|3 months||2 to 3 years|
|4 months||5 to 6 years|
|5 months||8 to 9 years|
|6 months||10 years|
|Junior||8 months||13 years|
|1 year||15 years|
|2 years||24 years|
|Prime||3 years||28 years|
|4 years||32 years|
|5 years||36 years|
|6 years||40 years|
|Mature||7 years||44 years|
|8 years||48 years|
|9 years||52 years|
|10 years||56 years|
|Senior||11 years||60 years|
|12 years||64 years|
|13 years||68 years|
|14 years||72 years|
|Geriatric||15 years||76 years|
|16 years||80 years|
|17 years||84 years|
|18 years||88 years|
|19 years||92 years|
|20 years||96 years|
|21 years and above||100 years|