write a program in Java to check whether a given year is leap year or not using nested ternary operator only..... Solve it with full steps
Answers
import java.util.Scanner;
public class Year1
{
void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("enter a no.");
int a=sc.nextInt();
if (a%100==0 && a%400==0)
System.out.println("leap year");
else if (a%100!=0 && a%4==0)
System.out.println("leap year");
else
System.out.println("non leap year");
}
}
Answer:import java.util.Scanner;
public class Year1
{
void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("enter a no.");
int a=sc.nextInt();
if (a%100==0 && a%400==0)
System.out.println("leap year");
else if (a%100!=0 && a%4==0)
System.out.println("leap year");
else
System.out.println("non leap year");
}
}
Read more on Brainly.in - https://brainly.in/question/1371111#readmore