Thursday, March 31, 2022

Java Program Conditional Statement PART - 4

 package selenium;

public class Conditionalstatement {

public static void main(String[] args) {

int number =6;

//using ternary

System.out.println(number%2==0 ? "Even Number" : "Odd Number");

int person_age =15;

//Using Ternary Operator

System.out.println(person_age>=18 ? "Eligible for vote" : "Not eligible for vote");

//IF ELSEIF CONDITION

int num=10;

if(num>0)

{

System.out.println("Number is positive");

}

else if (num<0) 

{

System.out.println("Number is negative");

}

else if (num==0) 

{

System.out.println("Number is zero");

}

}

}


No comments:

Post a Comment