Write a program the given year, leap year or not.
Using scanner class method
Using if else statement
Please answer it correctly
I will mark you as brainlist
Please answer it very fast
Answers
Answered by
1
Java Program to Find if a Given Year is a Leap Year
This is a Java Program to Find if a Given Year is a Leap Year.
Enter any year as an input. We first whether the given year is divisible by 400 or not. If it is divisible then it is a leap year else we check for further conditions. Now if it is divisible by 100 then it is not a leap year or else we further divide it by 4. If it is divisible then it is a leap year else its not.
Here is the source code of the Java Program to Find if a Given Year is a Leap Year. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
import java.util.Scanner;public class Check_Leap_Year { public static void main(String args[]) { Scanner s = new Scanner(System.in); System.out.print("Enter any year:"); int year = s.nextInt(); boolean flag = false; if(year % 400 == 0) { flag = true; } else if (year % 100 == 0) { flag = false; } else if(year % 4 == 0) { flag = true; } else { flag = false; } if(flag) { System.out.println("Year "+year+" is a Leap Year"); } else { System.out.println("Year "+year+" is not a Leap Year"); } }}
Output:
$ javac Check_Leap_Year.java $ java Check_Leap_Year Enter any year:1800 Year 1800 is not a Leap Year Enter any year:2000 Year 2000 is a Leap Year
Answered by
3
helpful...
HCl is a strong acid whereas acetic is a weaker acid. Fizzing occurs because of the production of the hydrogen gas obtained due to reaction of the acid on the magnesium ribbon. Since HCl is a very strong acid there is a lot of liberation of hydrogen gas from test tube A. therefore, more fizzing take place in test tube A....
Similar questions