This is a Java Program to Convert a Given Number of Days in terms of Years, Weeks & Days.

Enter any integer number as an input. After that we first divide the input by 365 to get number of years. After that we use modulus opeartion and division by 7 to get number of weeks. Finally we use modulo operation to get the number of days.

Here is the source code of the Java Program to Convert a Given Number of Days in terms of Years, Weeks & Days. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.

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);

`}`

`}`

advertisements

Output:

$ javac Year_Week_Day.java $ java Year_Week_Day Enter the number of days:756 No. of years:2 No. of weeks:3 No. of days:5

**Sanfoundry Global Education & Learning Series – 1000 Java Programs.**

Here’s the list of Best Reference Books in Java Programming, Data Structures and Algorithms.