Write a program that inputs age in years and displays age in days and months.

public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
int y,m,d;
System.out.println(“Enter age in year “);
y=cin.nextInt();
m=y*12;
d=y*365;
System.out.println(“days are=”+d);
System.out.println(“months are=”+m);
}

}

Output

run:
Enter age in year
18
days are=6570
months are=216
BUILD SUCCESSFUL (total time: 16 seconds)

Leave a Reply

Your email address will not be published. Required fields are marked *