Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!