Friday, 7 November 2014

PROGRAM TO FIND CORRESPONDING DAY OF THE YEAR

import java.util.*
class cdoy
{
public static void main(String args[])
{
Scanner sn=new Scanner(System.in);
int d,m,y,i,c;
int a[]={31,28,31,30,31,30,31,31,30,31,30,31};
System.out.println("enter date as dd,mm,yy);
d=sn.nextInt();
m=sn.nextInt();
y=sn.nextInt();

if((y%4==0 && y%100!=0) || Y%400==0)
{
a[1]=29;
}
c=0;
for(i=0;i<m;i++)
{
c=c+a[i];
}
c=c+d;
System.out.println("corresponding day of the year"+c);
}
}

No comments:

Post a Comment