Click the Twitter icon to follow our tweets and
know more about us.

WAP to enter a date and enter a number and then print the date after that number of days entered

import java.io.*;
class date
{
    public static void main()throws IOException
    {
        DataInputStream k=new DataInputStream(System.in);
        System.out.print("ENTER DATE");
        int dd=Integer.parseInt(k.readLine());
        System.out.print("ENTER MONTH");
        int mm=Integer.parseInt(k.readLine());
        System.out.print("ENTER YEAR");
        int yy=Integer.parseInt(k.readLine());
        System.out.print("ENTER NUMBER");
        int no=Integer.parseInt(k.readLine());
        dd=dd+no;
        int d[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
        if(yy%4==0)
        d[2]=29;
        while(dd>d[mm])
        {
            dd=dd-d[mm];
            mm++;
            if(mm==13)
            {
                mm=1;
                yy++;
            }
        }
        System.out.println("Date after "+no+" days is=  "+dd+"/"+mm+"/"+yy);
    }
}

Comments (0)

Post a Comment