码迷,mamicode.com
首页 > 其他好文 > 详细

HW3.18

时间:2016-08-12 18:11:27      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

 1 import javax.swing.JOptionPane;
 2 
 3 public class Solution
 4 {
 5     public static void main(String[] args)
 6     {
 7         String yearString = JOptionPane.showInputDialog(null, "Enter a year: \n", JOptionPane.QUESTION_MESSAGE);
 8         int year = Integer.parseInt(yearString);
 9 
10         boolean isLeapYear = ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
11 
12         String output = "";
13         if(isLeapYear)
14             output = year + " is a leap year";
15         else
16             output = year + " is not a leap year";
17 
18         JOptionPane.showMessageDialog(null, output);
19     }
20 }

 

HW3.18

标签:

原文地址:http://www.cnblogs.com/wood-python/p/5765689.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!