Human Years? Dog Years? How do I know?

Welcome to the Pet Age Calculator Project!

If you are a pet owner, you are in luck, as this site will answer:

How old is my dog/cat in 'human years?' Or, what equivalent developmental stage has my dog/cat reached?

If you a programmer or programming student, you are in luck, as this site will answer:

I am learning a new language, and have gotten past Hello World, Hello <<your name here>>, and unit conversion (Celcius-Fahreneit, Dollars-Euros, Joules-Calories, etc.) Now I need a good practical excercise to really begin to cement my understanding of these fundamentals. Got any suggestions?

I am seeking to create solutions in as many programming languages as possible, and present each of them here. The last link in the list is a zip file with all source code. I hereby release it to public domain. Use these as you like:

Note: The source also includes JSP, PHP, and ASP.NET versions, but I have not deployed them on this server. Questions or comments on anything are welcome at development(at)cobaltduck(dot)info.


Everyone has heard of the 'dog years' rule of seven to one. This still works as a very rough rule of thumb, but most veterinarians will tell you it is way too simplistic. For instance, most cats are able to have their first litter of kittens by age one. How many seven year old humans are that mature? Meanwhile, 15-year-old dogs are common, but 105 years for a human is a special acheivement. What is the real story?

You will probably not find universal agreement, but there are serveral points that sources seem to agree on:

Pooling the available information, I based my programs on the following formulas:

Thus from a code-writing stand-point, the task is this: Obtain input from the user about the size of the pet and current calendar age; asking the pet's name is also nice. Implement methods that calculate both the classic "dog years" (i.e. just multipy by 7) and also the age according to the formula above. Then output these values to the user. So the programs involve basic GUI i/o, some numeric computations, perhaps a couple if/then/else blocks, and the like.