ii)Simple if
class simple
{
public static void main(String [] args)
{
int a=20;
if (a>18)
{
System.out.println("Person is eligble for vote");
}
}
}
iii)if else
class age
{
public static void main(String [] args)
{
int a=20;
if (a>18)
{
System.out.println("Person is eligble for vote");
}
else
{
System.out.println("Person is not eligble for vote");
}
}
}
Nesting if
class age
{
public static void main(String [] args)
{
int a=20;
if (a>18 && a<35)
{
System.out.println("Person is able to marry");
}
else if(a>35)
{
System.out.println("Person is expire");
}
else
System.out.println("he is child");
}
}
No comments:
Post a Comment