Question: Java Programming: Design and implement an application (LeapYear) that reads an integer value representing a year from the user. The purpose of the program is

Java Programming:

Design and implement an application (LeapYear) that reads an integer value representing a year from the user. The purpose of the program is to determine if the year is a leap year (and thus has 29 days in February) in the Gregorian calendar. A year is a leap year if it is divisible by 4, unless it is also divisible by 100, or it is divisible by 400 (any year divisible by 400 is always a leap year). For example, the year 2003 is not a leap year (not divisible by 4), but 2004 is (divisible by 4, not divisible by 100). The year 1900 is not a leap year (it is divisible by 100). The year 2000 is a leap year even though it is divisible by 100 because it is also divisible by 400. [By divisible, we mean with no remainder]. Produce an error message for any input value less than 1582 (the year the Gregorian calendar was adopted by some countries). In your output, you should specifically test four numbers: 1200, 1900, 2000, and 2100 (because I will).

[Hint: you must use the modulus operator (%). Write out the problem in pseudo code first. You can do this problem with one if (plus nested ifs) for the leap year part]. Test by running the four outputsthis is what should happen:

1200: gives an error message that the user entered an invalid year (then closes the program)

1900: not a leap year

2000: is a leap year

2100: not a leap year

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!