So I created LeapYearCal this on If else statement I learn switch statement I want to recreate it using switch. Somehow my condition for leap is working, but I want to add condition like value must be in 1- 9999 only else it'll returned false. but when my code is incorrect How do I solve the problem?
public static boolean isLeapYear(int year)
{
switch ( year % 4)
{
case 0:
if (year % 100 == 0)
{
if ( (year % 400 == 0) )
{
if (year > 0)
{
if (year <= 9999)
{
return true;
}
else
return false;
}
else
return false;
}
else
return false;
}
else
return true;
default:
break;
}
return false;
I want to the output "True" if the year is Leap year and it's range 1-9999 else "False" if it is not in range regardless if its leap year
Aucun commentaire:
Enregistrer un commentaire