Question: I have this code that takes a dogs age and calculates its age in dog years. I would like to add to it that you
I have this code that takes a dogs age and calculates its age in dog years. I would like to add to it that you can enter your dogs name and the output would include the name. For example, you input and your dogs name is Lucy. It would print "Lucy's age in human years is:
Code:
import java.util.Scanner;
public class MyDog
public static void mainString args
Scanner scanner new ScannerSystemin;
user is prompted to enter their dogs age
System.out.printEnter your dog's age: ;
int dogYears scanner.nextInt;
int humanYears;
ifelse branch to determine the output of your dogs age
if dogYears
dogs age under is not a valid age
System.out.printlnInvalid age.";
return;
else if dogYears
dogs age in human years cannot be calculated until at least year old
System.out.printlnYour dogs age in human years cannot be calculated until it as at least one year old.";
return;
else if dogYears
the first year of a dogs life is equal to human years
humanYears ;
else if dogYears
the second year of a dogs life is equal to human years
humanYears ;
else
every year after the second year is equal to human years
humanYears dogYears ;
output prints the users dogs age in human years
System.out.printlnYour dog's age in human years is: humanYears;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
