Philip Hager wrote:Alright, I got it to work as expected now, not sure why it works correctly this way, but it does.
Well done! A few minor things for you to consider:
1.
isNotValidDate() should probably be called
invalidYear(). Ditto for the variable you assign it to.
2. You could make your
numDaysInMonth() method a lot more compact by storing month lengths in an array, viz:
3. You don't need to go overboard with brackets (although I understand why you did). Also:
Java has a '!=' operator, so:
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
will work just fine, and may be a bit clearer.
4. If you took the components in year, month, day order, you could check that each was valid
when it was entered.
I realise that probably wasn't the exercise here, but you might find
this page useful for some general tips on user input.
HIH
Winston