Determine If Year Is Leap Year
public class DetermineLeapYearExample
{
public static
void main(String[] args)
{
int year = 2004;
if((year % 400 == 0) || ((year % 4 == 0)
&& (year % 100 != 0)))
System.out.println("Year
" + year + " is a leap year");
else
System.out.println("Year
" + year + " is not a leap year");
}
}
If Else statement
public class
SimpleIfElseStatementExample
{
public static void
main(String[] args)
{
int i = 0;
if(i == 0)
System.out.println("i
is 0");
else
System.out.println("i
is not 0");
}
}
If Else If statement
public class IfElseIfElseExample
{
public static void main(String[] args)
{
int i = 10;
if(i > 100)
System.out.println("i is grater than
100");
else if(i > 50)
System.out.println("i is grater than
50");
else
System.out.println("i is less than
50");
}
}
If statement
public class
SimpleIfStatementExample
{
public static void main(String[] args)
{
boolean blnStatus = true;
if(blnStatus)
System.out.println("Status is true");
}
}
No comments:
Post a Comment