Posted by : Unknown
Sunday, 28 June 2015
Syntax:
if(condition 1)
statement 1;
else if (condition 2)
statement 2;
else if (condition 3)
statement 3;
statement 1;
else if (condition 2)
statement 2;
else if (condition 3)
statement 3;
else
statement 4;
Grade System 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 >= 90 )
{
System.out.println( "Grade A" );
}
else if ( mark >= 80 )
{
System.out.println( "Grade B" );
}
else if ( mark >= 70 )
{
System.out.println( "Grade C" );
}
else if ( mark >= 60 )
{
System.out.println( "Grade D" );
}
else if ( mark >= 50 )
{
System.out.println( "Grade E" );
}
else if ( mark >= 40 )
{
System.out.println( "Grade F" );
}
else
{
System.out.println( "Failed" );
}
}
}
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 >= 90 )
{
System.out.println( "Grade A" );
}
else if ( mark >= 80 )
{
System.out.println( "Grade B" );
}
else if ( mark >= 70 )
{
System.out.println( "Grade C" );
}
else if ( mark >= 60 )
{
System.out.println( "Grade D" );
}
else if ( mark >= 50 )
{
System.out.println( "Grade E" );
}
else if ( mark >= 40 )
{
System.out.println( "Grade F" );
}
else
{
System.out.println( "Failed" );
}
}
}
Output:
Enter your mark: 56
Grade E
Enter your mark: 10
Failed