HW3.18

HW3.18

 import javax.swing.JOptionPane;

 public class Solution
 {
     public static void main(String[] args)
     {
         String yearString = JOptionPane.showInputDialog(null, "Enter a year: \n", JOptionPane.QUESTION_MESSAGE);
         int year = Integer.parseInt(yearString);

         boolean isLeapYear = ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));

         String output = "";
         if(isLeapYear)
             output = year + " is a leap year";
         else
             output = year + " is not a leap year";

         JOptionPane.showMessageDialog(null, output);
     }
 }
上一篇:C# -- 扩展方法的应用(Extension Methods)


下一篇:UVA 11235 频繁出现的数值 RMQ