Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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 100

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

3. You can gain power by making others feel important.

Answered: 1 week ago