Conventionally it was thought that 1 year in a dog's age equals 7 years in human age. A fairly new concept in aging studies claims that chemical modifications to a person's DNA over a lifetime essentially serve as an "epigenetic clock." This tracks an individual's "biological age". The “epigenetic clock” also applies to dogs. The most precise method to convert a dog’s age to human years uses the empirical equation that the researchers in aging studies discovered, which is 16 x ln(dog’s age) +31 = human age, (that is the natural logarithm of the dog’s real age, multiplied by 16, with 31 added to the total.) Write two overloaded functions to calculate a dog’s age in human years, one using the conventional method (simply multiplying the dog’s age in years by 7) and the other using the empirical equation proposed by the researchers in aging studies (16 x ln(dog’s age) + 31 = human age).
#include <iostream>
#include <cmath>
using namespace std;
int Age(int dogAge);
int Age(double dogAge);
int main()
{
int dogAge = 0;
cout << "Enter dog age: ";
cin >> dogAge;
cout << endl;
cout << "Dog to human age (old version): " << Age(dogAge) << " years." << endl;
cout << "Dog to human age (new version): " << Age((double)dogAge) << " years." << endl;
}
int Age(int dogAge)
{
return dogAge * 7;
}
int Age(double dogAge)
{
return 16 * log(dogAge) + 31;
}
Comments
Leave a comment