Java Program to convert number of days into no. of years, months, weeks and days…

This java code will convert a given number of days into no. of years, months, weeks and days.
class Mnth
{
                public static void main(String args[])
                {
                                int d,m,w,y;
                                d=Integer.parseInt(args[0]);
                                y=d/365;
                                d=d%365;
                                m=d/30;
                                d=d%30;
                                w=d/7;
                                d=d%7;
                                System.out.println(“Years=”+y);
                                System.out.println(“Months=”+m);
                                System.out.println(“Weeks=”+w);
                                System.out.println(“Days=”+d);                               
                }
}

Add Comment