Question
Write a program that reads an integer value from the user representing a year. Determine if the year is a leap year and output either:
Write a program that reads an integer value from the user representing a year. Determine if the year is a leap year and output either:
xxxx is a leap year OR
xxxx is not a leap year
where xxxx is the year entered.
A year is a leap year if it is divisible by 4 except when it is also divisible by 100 but not divisible by 400. If it is not divisible by 4 then it is NOT a leap year.
For example, 2015 is not a leap year but 2016 is. 2000 is a leap year but 1900 was not a leap year (divisible by 100 but not 400).
Produce an error message for any input value less than 1582 (the year the Gregorian calendar was adopted).
Add an underscore and your initials to both the class name (public class LeapYear_DBS, for example) and the file name (LeapYear_DBS.java), compile and run it to make sure it works, and submit via D2L.
BONUS: Use a while loop to allow the user to enter multiple years. They will enter a year, your program outputs whether it is a leap year then you prompt the user to see if they want to enter another year (y/n). If so, you check to see if it is a leap year and then if they want to enter another 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