3. Dog Age Calculator You know how old your dog is in human years, but what abou
ID: 3734551 • Letter: 3
Question
3. Dog Age Calculator
You know how old your dog is in human years, but what about dog years? Calculate it!
Write a function named calculateDogAge that:
takes 1 argument: your puppy's age.
calculates your dog's age based on the conversion rate of 1 human year to 7 dog years.
outputs the result to the screen like so: "Your doggie is NN years old in dog years!"
Call the function three times with different sets of values.
Add an additional argument to the function that takes the conversion rate of human to dog years.
Explanation / Answer
function calculateDogAge(puppyAge,conversionRate) {
print("Your doggie is "+puppyAge*conversionRate+" years old in dog years!");
}
calculateDogAge(4,7);
calculateDogAge(1,6);
calculateDogAge(4,8);
Output:
Your doggie is 28 years old in dog years!
Your doggie is 6 years old in dog years!
Your doggie is 32 years old in dog years!
Do ask if any query. Please upvote if the result is useful.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.