//for dialog box to work import javax.swing.JOptionPane; public class DaysInMonth{ public static void main(String[] args){ //Ask user to input data String stringmonth = JOptionPane.showInputDialog(null, "Please input a month in numbers 1-12", "CPSC 1150 Lab 4", JOptionPane.QUESTION_MESSAGE); String stringyear = JOptionPane.showInputDialog(null, "Please input a year", "CPSC 1150 Lab 4", JOptionPane.QUESTION_MESSAGE); //Turn String into integers int month = Integer.parseInt(stringmonth); int year = Integer.parseInt(stringyear); //Display information according to month switch(month){ case 1: JOptionPane.showMessageDialog(null, "January of "+year+" has 31 days"); break; //Display information according to year case 2: if(year%4==0){ if(year%100 != 0){ JOptionPane.showMessageDialog(null, "Februrary of "+year+" is a leap year and has 29 days"); break; } else if(year%400==0) { JOptionPane.showMessageDialog(null, "Februrary of "+year+" is a leap year and has 29 days"); break; } else { JOptionPane.showMessageDialog(null, "Februrary of "+year+" is NOT a leap year and has 28 days"); break; } } else { JOptionPane.showMessageDialog(null, "Februrary of "+year+" is NOT a leap year and has 28 days"); break; } case 3: JOptionPane.showMessageDialog(null, "March of "+year+" has 31 days"); break; case 4: JOptionPane.showMessageDialog(null, "April of "+year+" has 30 days"); break; case 5: JOptionPane.showMessageDialog(null, "May of "+year+" has 31 days"); break; case 6: JOptionPane.showMessageDialog(null, "June of "+year+" has 30 days"); break; case 7: JOptionPane.showMessageDialog(null, "July of "+year+" has 30 days"); break; case 8: JOptionPane.showMessageDialog(null, "August of "+year+" has 31 days"); break; case 9: JOptionPane.showMessageDialog(null, "September of "+year+" has 30 days"); break; case 10: JOptionPane.showMessageDialog(null, "October of "+year+" has 31 days"); break; case 11: JOptionPane.showMessageDialog(null, "November of "+year+" has 30 days"); break; case 12: JOptionPane.showMessageDialog(null, "December of "+year+" has 31 days"); break; } } }