java中的小程序,在eclipse中能正常运行,但是在cmd中运行时会出现wrong,各位能人帮帮忙!
源程序:packagezxc;importjavax.swing.JOptionPane;publicclassId{/***@paramargs*/publicstat...
源程序:
package zxc;import javax.swing.JOptionPane;public class Id {
/** * @param args */ public static void main(String[] args) { String ID; int year,month,day,lent,province; ID=JOptionPane.showInputDialog("Input your ID "); lent=ID.length(); if(lent!=18) { JOptionPane.showMessageDialog(null, "The length of your ID inputed is error!", "warning", 0); return; } province=Integer.parseInt(ID.substring(0, 2)); year=Integer.parseInt(ID.substring(6,10)); month=Integer.parseInt(ID.substring(10,12)); day=Integer.parseInt(ID.substring(12, 14)); int array[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; if(province<=00||province>=51) { JOptionPane.showMessageDialog(null, "The province code inputed is error!", "warning", 0); } else if(year<1900||year>=2015) { JOptionPane.showMessageDialog(null, "The year is error!", "warning", 0); } else if(month<1||month>12) { JOptionPane.showMessageDialog(null, "The month is error!", "warning", 0); } else if(year%400==0||(year%4==0&&year%100!=0)) { if(month==2&&(day>29||day<=0)) JOptionPane.showMessageDialog(null, "The day is error!", "warning", 0); } else if(array[month]<=day||day<=0) JOptionPane.showMessageDialog(null, "tHE birthday is error!", "warning", 0); else JOptionPane.showMessageDialog(null, "The ID is right", "yes", JOptionPane.PLAIN_MESSAGE); // TODO Auto-generated method stub }
} 展开
package zxc;import javax.swing.JOptionPane;public class Id {
/** * @param args */ public static void main(String[] args) { String ID; int year,month,day,lent,province; ID=JOptionPane.showInputDialog("Input your ID "); lent=ID.length(); if(lent!=18) { JOptionPane.showMessageDialog(null, "The length of your ID inputed is error!", "warning", 0); return; } province=Integer.parseInt(ID.substring(0, 2)); year=Integer.parseInt(ID.substring(6,10)); month=Integer.parseInt(ID.substring(10,12)); day=Integer.parseInt(ID.substring(12, 14)); int array[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; if(province<=00||province>=51) { JOptionPane.showMessageDialog(null, "The province code inputed is error!", "warning", 0); } else if(year<1900||year>=2015) { JOptionPane.showMessageDialog(null, "The year is error!", "warning", 0); } else if(month<1||month>12) { JOptionPane.showMessageDialog(null, "The month is error!", "warning", 0); } else if(year%400==0||(year%4==0&&year%100!=0)) { if(month==2&&(day>29||day<=0)) JOptionPane.showMessageDialog(null, "The day is error!", "warning", 0); } else if(array[month]<=day||day<=0) JOptionPane.showMessageDialog(null, "tHE birthday is error!", "warning", 0); else JOptionPane.showMessageDialog(null, "The ID is right", "yes", JOptionPane.PLAIN_MESSAGE); // TODO Auto-generated method stub }
} 展开
展开全部
你用javac编译了吗?先编译,后运行~
追问
编译过了,在eclipse中正常,在cmd中就不行了
追答
在cmd重新编译看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没先用javac预先编译吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询