TH CODE :
import java.util.Scanner;
/**
*
*/
public class q {
public static void main(String[] args) {
int month=0;
int day =0;
int daysInMonth;
int year=0;
boolean monthValid, yearValid, dayValid;
boolean leapYear;
Scanner kbd = new Scanner(System.in);
// Progams information
System.out.println("Date Checker") ;
System.out.println("------------");
System.out.println();
System.out.println();
System.out.println("I will check if the date you enter is valid.");
System.out.println();
System.out.println("Enter the date below. Use the form /day month year/");
System.out.println("(e.g. 29 February 1066).");
day = kbd.nextInt(); month = kbd.nextInt(); year = kbd.nextInt();kbd.nextLine();
// leap year
leapYear =(((year % 4) == 0) && ((year % 100) != 0) || ((year % 400) == 0));
// number days in month
if ((month == 1) || (month == 3) || (month==7) || (month == 8) || ( month == 10) || ( month == 12))
daysInMonth=31;
if ((month == 4) || (month == 6) || (month == 9) || ( month == 11))
daysInMonth=30;
if (month == 2)
daysInMonth=28;
if (leapYear)
daysInMonth=29;
{
System.out.println(day+" "+month+" "+year+" is a valid date!");
}
else if
{
System.out.println(day+" "+month+" "+year+" is not a valid date!");
}
}
}
This post has been edited by The92: 03 October 2011 - 10:28 AM

New Topic/Question
Reply



MultiQuote





|