165,387 views
0 votes
0 votes
Write a java program to take number of years, months and days from the user and print the total number of days (Consider 30 days in a month).​

User Jarsen
by
2.4k points

1 Answer

19 votes
19 votes

Answer:

Step-by-step explanation:

import java.util.Scanner;

public class Year_Week_Day

{

public static void main(String args[])

{

int m, year, week, day;

Scanner s = new Scanner(System.in);

System.out.print("Enter the number of days:");

m = s.nextInt();

year = m / 365;

m = m % 365;

System.out.println("No. of years:"+year);

week = m / 7;

m = m % 7;

System.out.println("No. of weeks:"+week);

day = m;

System.out.println("No. of days:"+day);

}

}

User Emon
by
3.2k points