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); } }
相关文章
- 09-22HW3.18