단순 프로그래밍 (4) 은 사용자에게 한 해와 한 달을 입력해서 그 해가 몇 날인지 판단하도록 요구한다.

사용자에게 한 해와 한 달을 입력하여 그 해가 몇 날인지 판단하도록 요구하다.
Java 프로그래밍
이 프로그램이 좀 복잡한 것 같아요. 헤헤.
import javax.swing.JOptionPane;




public class mm {


/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String num1;
String num2;

int n1;
int n2;


num1=JOptionPane.showInputDialog("       :");

num2=JOptionPane.showInputDialog("       :");

n1=Integer.parseInt(num1);
n2=Integer.parseInt(num2);

if((n1%4==0&&n1%100!=0) ||(n1%400==0)) {

if(n2==2)

{JOptionPane.showMessageDialog(null,"   29 ");}

if(n2==1||n2==3||n2==5||n2==7||n2==8||n2==10||n2==12)

{JOptionPane.showMessageDialog(null,"   31 ");}

if(n2==4||n2==6||n2==9||n2==11)

{JOptionPane.showMessageDialog(null,"   30 ");}}




else 

{if(n2==2)

{JOptionPane.showMessageDialog(null,"   28 ");}

if(n2==1||n2==3||n2==5||n2==7||n2==8||n2==10||n2==12)

{JOptionPane.showMessageDialog(null,"   31 ");}

if(n2==4||n2==6||n2==9||n2==11)

{JOptionPane.showMessageDialog(null,"   30 ");}}

}

}

좋은 웹페이지 즐겨찾기