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");
}
*/
}
}

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay