Posted by : Unknown
Sunday, 28 June 2015
Syntax:
if(condition)
statement 1;
else
statement 2;
statement 1;
else
statement 2;
Program:
import java.util.Scanner;
class result
{
public static void main(String[] args)
{
int mark;
Scanner s=new Scanner(System.in);
System.out.print("Enter your mark: ");
mark=s.nextInt();
if ( mark <= 60 )
{
System.out.println("Fail");
}
else
{
System.out.println("Pass");
}
}
}
class result
{
public static void main(String[] args)
{
int mark;
Scanner s=new Scanner(System.in);
System.out.print("Enter your mark: ");
mark=s.nextInt();
if ( mark <= 60 )
{
System.out.println("Fail");
}
else
{
System.out.println("Pass");
}
}
}
Output:
Enter your mark: 23
Fail
Enter your mark: 56
Pass
Fail
Enter your mark: 56
Pass