Computer Science, asked by fgbvbj, 1 year ago

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

Answered by lyric
3

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");

}

}

Answered by shirisha1981
0

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

Similar questions