Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java / / if year is divisble by 4 if ( year % 4 = = 0 ) { / / if year is divisble

java // if year is divisble by 4
if(year %4==0){
// if year is divisble by 100 it should also be divisble by 100
if( year %100==0){
// it's a leap year since it is divisible by 400
if ( year %400==0)
isLeapYear = true;
// else - it is century year but not divisible by 400 so not a leap year
else
isLeapYear = false;
}
// it is not a century year but divisible by 4,so it's a leap year
else
isLeapYear = true;
}
// not divisible by 4,so it is not a leap year
else
isLeapYear = false;
// displaying if it is a leap year or not
if(isLeapYear)
System.out.println(year +"- leap year");
else
System.out.println(year +"- not a leap 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 Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions