boolean leap_year;
int year,m;
String month,year2,answer;
month = JOptionPane.showInputDialog("Enter a month");
m=Integer.parseInt(month);
switch(m)
{
case 1: answer="The number of days on month Jan is: 31";
break;
case 2:
year2= JOptionPane.showInputDialog("Enter a year");
year=Integer.parseInt(year2);
if (leap_year=( ((year%4==0)&&(year%100!=0))||(year%400==0) ))
answer="The number of days on month Feb and year "+year+" is 29";
else
answer="The number of days on month Feb and year "+year+" is 28";
break;
case 3:
answer="The number of days on month Mar is: 31";
break;
case 4:
answer="The number of days on month App is: 30";
break;
case 5:
answer="The number of days on month May is: 31";
break;
case 6:
answer="The number of days on month Jun is: 31";
break;
case 7:
answer="The number of days on month Jul is: 31";
break;
case 8:
answer="The number of days on month Aug is: 31";
break;
case 9:
answer="The number of days on month Sep is: 30";
break;
case 10:
answer="The number of days on month Oct is: 31";
break;
case 11:
answer="The number of days on month Nev is: 30";
break;
case 12:
answer="The number of days on month Dec is: 31";
break;
}
JOptionPane.showMessageDialog(null,answer,"result",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
number.java:55: variable answer might not have been initialized
JOptionPane.showMessageDialog(null,answer,"result",JOptionPane.INFORM
^
ATION_MESSAGE);
1 error
how can i solve the problem?