Saturday, June 2, 2012

If-Else Statement:

If-Else Statement:

The if-else class of statements should have the following form:
 if (condition) 
{
statements;
else 
{
statements;
}

PROGRAM:
import.java.io.*;
public class divisor
{
public static void main(String[] args)

{
         int a = 10;
         int b = 2;
         if ( a % b == 0 )
         {
               System.out.println(a + " is divisible by "+ b);
         }
         else
         {
               System.out.println(a + " is not divisible by " + b);
         }
}


TRY YOURSELF:5
1)Write a program to whether the Arun is eligible to vote age limit to vote must be 18 years,use if else statement and display his eligibility.

No comments:

Post a Comment

Animated Social Gadget - Blogger And Wordpress Tips