Sunday, April 4, 2010

If Statement

if statement is a conditional statement in programming. In this statement we are using the conditonal operators. this is true or false only. if the conditional statement is true the program execute the true statements, if the conditional statement is false the program execute the false statements.

sample program:

this program will show to you if the grade of students is greater than 75 the program will show message "Your passed" else "Sorry your Failed".

import java.io.*;

public class sample
{
public static void main(String args[])
{
int average=75;

if(average>=75)
{
System.out.print("Your Passed");
}
else
{
System.out.print("Your Failed");
}

}

}

No comments:

Post a Comment