// A Program to validate the date//
import java.io.*;
public class datevalid
{
public static void main (String [] args) throws IOException
{
BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
System.out.println("ENTER THE DATE");
String str=br.readLine();
int date=Integer.parseInt(str);
System.out.println("ENTER THE MONTH");
String str1=br.readLine();
int month=Integer.parseInt(str1);
System.out.println("ENTER THE YEAR");
String str2=br.readLine();
int year=Integer.parseInt(str2);
if(year>0&&year<=2009)
{
if(month>=1&&month<=12)
{
if(date>=1&&date<=31)
{
if(date>28&&month==2&&(year%4!=0))
System.out.println("WRONG DATE");
else if(date>29&&month==2&&(year%4==0))
System.out.println("WRONG DATE");
else if(date>30&&(month==4||month==6||month==9||month==11))
System.out.println("WRONG DATE");
else if(date>31&&(month==1||month==3||month==5||month==7||month==8||month==10||month==12))
System.out.println("WRONG DATE");
else
System.out.println("CORRECT DATE");
}
else
System.out.println("WRONG DATE");
}
else
System.out.println("WRONG DATE");
}
else
System.out.println("WRONG DATE");
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment