Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner; // import Scanner method
- public class (Name) // This is your file name
- {
- public static void main(String [] args) // main method (whatever other method do, this method will be the end of your code)
- {
- System.out.print("What is your year?");
- Scanner in = new Scanner (System.in);
- int year = in.nextInt(); // Scan your number (it can be any number except number with floating points)
- System.out.print("The answer is "+isLeapYear(year));
- }
- public static boolean isLeapYear(int year) // new method (sub-method)
- {
- if (year%4 == 0 && year%100 != 0 || year%400 == 0) // check about year
- {
- return true; // if year is true in above condition this will be represent
- } else { // whatever that not make the above condition true
- return false;
- }
- }
- }
- // PS. %(mod) is operator
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement