ValidDate

ValidDate - else if (month == 5) daysInMonth = 30; else if...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.Scanner; i public class ValidDate { p public static void main(String[] args) { // TODO Auto-generated method stub / int day, month, year, daysInMonth; i Scanner keyboard = new Scanner(System.in); S System.out.println("Enter a year between 1200 and 2050: "); year = keyboard.nextInt(); System.out.println("Please enter a month: "); month = keyboard.nextInt(); System.out.println("Please enter a day: "); day = keyboard.nextInt(); d if (month == 1) daysInMonth = 31; else if (month == 3) daysInMonth = 31; else if (month == 4) daysInMonth = 30;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: else if (month == 5) daysInMonth = 30; else if (month == 6) daysInMonth = 30; else if (month == 7) daysInMonth = 31; else if (month == 8) daysInMonth = 31; else if (month == 9) daysInMonth = 30; else if (month == 10) daysInMonth = 31; else if (month ==11) daysInMonth = 30; else if (month == 12) daysInMonth = 31; else { if ((year%4 == 0 && year%100!=0 || year%100==0 && year%400==0)){ daysInMonth=29; }else daysInMonth=28; } if (day <= daysInMonth){ System.out.println("valid"); }else{ System.out.println("invalid"); } } } } }...
View Full Document

This note was uploaded on 11/15/2010 for the course CSCI 01209 taught by Professor Storm during the Fall '10 term at UGA.

Ask a homework question - tutors are online