COS1512 ASSIGNMENT 2 SOLUTIONS 2021
Question 1)
#include <iostream>
#include <cmath>
using namespace std;
int Age(int dogAge)
{
return dogAge * 7;
}
int Age(double dogAge)
{
return 16 * log(dogAge) + 31;
}
int main()
{
int dogAge;
cout << "Enter dog age: ";
cin >> dogAge;
cout << endl;
cout << "Dog to human age (conventional method): " << Age(dogAge) << " years." << endl;
cout << "Dog to human age (empirical equation): " << Age((double)dogAge) << " years." << endl;
}
Question 1)
#include <iostream>
#include <cmath>
using namespace std;
int Age(int dogAge)
{
return dogAge * 7;
}
int Age(double dogAge)
{
return 16 * log(dogAge) + 31;
}
int main()
{
int dogAge;
cout << "Enter dog age: ";
cin >> dogAge;
cout << endl;
cout << "Dog to human age (conventional method): " << Age(dogAge) << " years." << endl;
cout << "Dog to human age (empirical equation): " << Age((double)dogAge) << " years." << endl;
}