Thursday , September 21 2017
Home / JAVA / program in Java/ Bluej to display the present date and the date after N days

program in Java/ Bluej to display the present date and the date after N days

Q. Write a program to input the number of days, year and integer N and display the present date and date after N Days.

class iscdate2
{
void calc(int yr,int cd,int n1)
{
String m[]={"jan","feb","march","april","may","june","july","august","september","october","november", "december"};
{
int a[]={31,29,31,30,31,30,31,31,30,31,30,31};
int b[]={31,28,31,30,31,30,31,31,30,31,30,31};
int t=0,d,c,i;
c=(n1/30+1);
for(i=0;i<c;i++)
{
if(yr%4==0)
t+=a[i];
else
t+=b[i];
if(t>n1)
{
if(n1>30)
d=n1-t+a[i];
else
d=n1;
if(cd==1)
System.out.println("present date:"+d+m[i]+yr);
else
System.out.println("date after"+cd+"day is:"+d+m[i]+yr);
break;
}
}}}
public static void main(int y,int n,int N)
{
iscdate2 ob=new iscdate2();
ob.calc(y,1,n);
if(n+N>366)
{
int z=n+N-366;
ob.calc(y+1,N,2);
}
else
ob.calc(y,N,n+N);
}}

Check Also

Program to check Upper Triangular matrix

What is Upper Triangular Matrix?  An upper triangular matrix is a square matrix in which ...

Leave a Reply

Your email address will not be published. Required fields are marked *