Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

2 The main characteristics of the market system.

Answered: 1 week ago