View Code of Problem 28

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{

    public static void main(String[] args) throws IOException {
//        Scanner scanner = new Scanner(System.in);
//        while (scanner.hasNext()) {
//            int a = scanner.nextInt();
//            //rs.add(judge(a) ? "Leap Year" : "Not Leap Year");
//            System.out.println(((a % 4 == 0 && a % 100 != 0) || (a % 400 == 0)) ? "Leap Year" : "Not Leap Year");
//        }
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String s = bf.readLine();
        if(s!=null) {
            do {
                int year = Integer.valueOf(s);
                if ((year % 4 == 0 && year % 100 != 0) ||
                        year % 400 == 0) {
                    System.out.println("Leap Year");
                } else {
                    System.out.println("Not Leap Year");
                }
                s = bf.readLine();
            } while (s != null);
        }
    }
}

Double click to view unformatted code.


Back to problem 28