DEV Community

Harish R
Harish R

Posted on

IF TYPES (today topic)

package ifmodel;

public class Ifmodel {

public static void main(String[] args{
Enter fullscreen mode Exit fullscreen mode

/* IFONLY
int i=30;
int j=10;
if(i>j) {
System.out.println("true"); //ANS=true
}
/
/

//IF ELSE
// int i=10;
// int j=20;
if(i>j){

System.out.print("i is high"); 
Enter fullscreen mode Exit fullscreen mode

}
else //ANS =j is high
{
System.out.print("j is high");
}
/
/

// CONDITIONAL STATEMENT
int i=10;
int j=10;
if(i System.out.print("i is high");
}
else if( j>i) {
System.out.print("j is high");
}
else { //ANS = both are same
System.out.print("both are same");
}
*/

    /*// conditional NESTED IF
Enter fullscreen mode Exit fullscreen mode

int i=101;

if(i>=45 && i<=100)
{
if(90<=i && 100>=i) {
System.out.println("a grade");
}
else if(80<=i && i<=89)
{
System.out.println("b grade");
}
else if(70<=i && i<=79) {
System.out.println("c grade");
}
else // ANS= FAIL
{
System.out.println("d grade");
}

}
else
{
System.out.println("fail");
}
*/
}
}

Top comments (0)