Wap to use Ternary Operator in Java
import java.util.Scanner;
class Ternary
{
public static void main(String []arg)
{
Scanner scanner = new Scanner(System.in);
int feb;
System.out.print("Enter the no of days in February month:");
feb =scanner.nextInt();
System.out.println((feb==28) ? "The is a Leap Year" : "This is not a Leap Year");
}
}
Comments
Post a Comment