Question
I need help with a Java Program: As the earth orbits around the sun, it takes 365 and one quarter days to complete an orbit.
I need help with a Java Program:
As the earth orbits around the sun, it takes 365 and one quarter days to complete an orbit. To make the adjustment for the quarter day, we add one day every 4 years to the calendar and thats the origin of the leap year. However, in so doing, there is a slight error that creeps in and to compensate for this error, years those are divisible by 100, but not by 400 are not considered leap years.
Definition of a leap year: If a number is not divisible by 4, it is not a leap year. ?
If a number is divisible by 100 but not by 400, it is not a leap year. ?
If a number is divisible by 100 and 400, it is a leap year. ?
If a number is not divisible by 100 but divisible by 4, it is a leap year. Examples: Case 1: 1991, 2001 and 2005 are not leap years.
Case 2: 1800 and 1900 are not leap years.
Case 3: 1600 and 2000 are leap years.
Case 4: 1992, 1996 and 2008 are leap years. You have to write a Java program that allows user to enter a number greater that 100 as the year and print a message saying whether it is a leap year or not.
Note that, if user enter a number less than or equal to 100, then your program should display an error message.
Sample interfaces for the program: Enter a year greater than 100: 1996 1996 is a leap year! or Enter a year greater than 100: 2001 2001 is not a leap year! or Enter a year greater than 100: 90 Error Year is less than or equals to 100Step 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