How to use Nested if else in java

Nested if else use for check the multiple condition. In nested if else, the level of nested if statement are more than three. If statements can be nested where multiple tests are necessary, however, this approach is not generally recommended because on has to maintain a mental stack of the decision being made,

//Code for Nested Ifelse

class Ifelse
{
public static void main(String[] args)
{
int marks = 76;
char grade;

if(marks>=90)
{
grade ="A+";
}

else if(marks>=70)
{
grade ="A";
}
else if(marks>=60)
{
grade ="B";
}
else
{
grade ="C";
}
System.out.println("Grade= "+grade);
}
}

happy Codding..

Tags: ,