LoginSignup
0
0

More than 5 years have passed since last update.

暦の判定

Last updated at Posted at 2019-04-11

暦を判定するプログラムを作成する。

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int reki = sc.nextInt();
        String hantei = "";
        if(reki%4==0){
            hantei="閏年";
            if(reki%400!=0 && reki%100==0){
                hantei="平年";
            }else{
                hantei="閏年";
            }
        }else{
            hantei="平年";
        }
        System.out.println(hantei);
    }
}

//1900と入力すると平年と出る
//2000と入力すると閏年と出る
//2001と入力すると平年と出る
//2004と入力すると閏年と出る
0
0
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0