Write a Java program to convert days into years, weeks and days.
(hint)
year = days/365
week = (day % 365)/7)
days = days-(year*365)+(weeks*7))
Static :-
class YWD
{
public static void main(String args[])
{
int day=500;
int year,week,days;
year = (day/365);
week = (day % 365)/7;
days = day-((year*365)+(week*7));
System.out.println("The number of year :- "+year);
System.out.println("The number of week :- "+week);
System.out.println("The number of days :- "+days);
}
}
Output :-
Dynamic :-
import java.util.*;
class YWD
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter the number of Days :- ");
int day = in.nextInt();
int year,week,days;
year = (day/365);
week = (day % 365)/7;
days = day-((year*365)+(week*7));
System.out.println("The number of year :- "+year);
System.out.println("The number of week :- "+week);
System.out.println("The number of days :- "+days);
}
}
Output :-