以下是今天的作业,纠结了很久,结合这几天讲的东西写出来的,大家有意见多提哈
import javax.swing.JOptionPane;
public class tianshu {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String year =JOptionPane.showInputDialog(null,"请输入年份");
String month =JOptionPane.showInputDialog(null,"请输入月份");
String day =JOptionPane.showInputDialog(null,"请输入号数");
int a =Integer.parseInt(year);
int b =Integer.parseInt(month);
int c =Integer.parseInt(day);
int c1=31;
int c2=28;
int c3=29;
int c4=30;
if(b == 1 && (c<=31)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+c+"天");
}
else if(b == 2 && (a%4 == 0) && (c<=29)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1)+"天");
}
else if(b == 2 && (a%4 == 0) && (c<=28)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1)+"天");
}
else if((a%4 == 0) && (b == 3) && (c<=31)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c3)+"天");
}
else if((a%4 != 0) && (b == 3) && (c<=31)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c2)+"天");
}
else if((a%4 == 0) && (b == 4) && (c<=30)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c3+c1)+"天");
}
else if((a%4 != 0) && (b == 4) && (c<=30)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c2+c1)+"天");
}
else if((a%4 == 0) && (b == 5) && (c<=31)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c3+c1+c4)+"天");
}
else if((a%4 != 0) && (b == 5) && (c<=31)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c2+c1+c4)+"天");
}
else if((a%4 == 0) && (b == 6) && (c<=30)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c3+c1+c4+c1)+"天");
}
else if((a%4 != 0) && (b == 6) && (c<=30)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c2+c1+c4+c1)+"天");
} else if((a%4 == 0) && (b == 7) && (c<=31)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c3+c1+c4+c1+c4)+"天");
}
else if((a%4 != 0) && (b == 7) && (c<=31)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c2+c1+c4+c1+c4)+"天");
} else if((a%4 == 0) && (b == 8) && (c<=31)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c3+c1+c4+c1+c4+c1)+"天");
}
else if((a%4 != 0) && (b == 8) && (c<=31)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c2+c1+c4+c1+c4+c1)+"天");
}
else if((a%4 == 0) && (b == 9) && (c<=30)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c3+c1+c4+c1+c4+c1+c1)+"天");
}
else if((a%4 != 0) && (b == 9) && (c<=30)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c2+c1+c4+c1+c4+c1+c1)+"天");
} else if((a%4 == 0) && (b == 10 && (c<=31))){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c3+c1+c4+c1+c4+c1+c1+c4)+"天");
}
else if((a%4 != 0) && (b == 10) && (c<=31)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c2+c1+c4+c1+c4+c1+c1+c4)+"天");
}
else if((a%4 == 0) && (b == 11) && (c<=30)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c3+c1+c4+c1+c4+c1+c1+c4+c1)+"天");
}
else if((a%4 != 0) && (b == 11) && (c<=30)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c2+c1+c4+c1+c4+c1+c1+c4+c1)+"天");
}
else if((a%4 == 0) && (b == 12) && (c<=31)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c3+c1+c4+c1+c4+c1+c1+c4+c1+c4)+"天");
}
else if((a%4 != 0) && (b == 12) && (c<=31)){
JOptionPane.showMessageDialog(null, "是"+a+"年的第"+(c+c1+c2+c1+c4+c1+c4+c1+c1+c4+c1+c4)+"天");
}
else{
JOptionPane.showMessageDialog(null,"输入错误");
}
}
}