Question
Java Programming 1. Ask the user for a year as an input (positive integer - should be between 1500 and 2020, and can include 1500
Java Programming
1. Ask the user for a year as an input (positive integer - should be between 1500 and 2020, and can include 1500 and 2020).
2. If the year input is not between 1500 and 2020, do not check for leap year. Instead, print that this year cannot be checked.
3. If the input year provided by the user is a leap year, print that year is a leap year. Otherwise, print that the year is not a leap year.
how to check if its a leap year
There are a few things to check:
- First, if the year can be divided by 4 evenly, it is a leap year.
- HOWEVER! If the year can be divided by 100 evenly, it is NOT a leap year! (If this occurs, check if the year can divided by 400 evenly. If it is divisible by both 100 evenly, and 400 evenly, it will be considered a leap year.) You'll need to do this to handle centurial years, i.e., years ending in 00, e.g., 1900, 1800, 1700, 2000 etc.
Sample output
The output should look like this:
- What year do you want to test? (make sure it's between 1500 and 2020): 1400
This year cannot be checked. Try again!
- What year do you want to test? (make sure it's between 1500 and 2020): 2021
This year cannot be checked. Try again!
- What year do you want to test? (make sure it's between 1500 and 2020): 2016
-
Yes, 2016 is a leap year!
- What year do you want to test? (make sure it's between 1500 and 2020): 1900
-
Nope, 1900 is NOT a leap year!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started