Write a Java program to display whether the given year is a leap year or not , using a turnery (conditional) operator.
Please give me the Program.
Answers
Answered by
3
Hiii....
Programm....
public class Leap year {
public static void main ( string [ ] args ) {
int year = 1900 ;
boolean leap = false ;
if ( year % 4 = = 0 )
{
if ( year % 100 = = 0 )
{
// year is divisible by 400 , hence year ia leap year
if ( year % 400 = = 0 )
leap = true ;
else
leap = false ;
}
else
leap = true ;
}
else
leap = false ;
if ( leap)
system . out .println ( year + " is a leap year " )
else
system.out.println ( year + " is not a leap year " )
}
}
I hope it helps........☺☺☺☺☺☺
Programm....
public class Leap year {
public static void main ( string [ ] args ) {
int year = 1900 ;
boolean leap = false ;
if ( year % 4 = = 0 )
{
if ( year % 100 = = 0 )
{
// year is divisible by 400 , hence year ia leap year
if ( year % 400 = = 0 )
leap = true ;
else
leap = false ;
}
else
leap = true ;
}
else
leap = false ;
if ( leap)
system . out .println ( year + " is a leap year " )
else
system.out.println ( year + " is not a leap year " )
}
}
I hope it helps........☺☺☺☺☺☺
GB2010:
My programm is absolutely true...
Similar questions