谢谢各位的回复,全角是我打字的疏忽。我写的程序是这样的,但是中间部分太麻烦,所以想简写一下
import javax.swing.*;public class good1 {
public static void main(String args[])
{
String inputString;
int a, b, c, d, e, f, g, h, i, j, X, x, y; inputString = JOptionPane.showInputDialog("Enter Student ID number" );
X = Integer.parseInt(inputString);
a = X/100000000;
b = X/10000000-a*10;
c = X/1000000-a*100-b*10;
d = X/100000-a*1000-b*100-c*10;
e = X/10000-a*10000-b*1000-c*100-d*10;
f = X/1000-a*100000-b*10000-c*1000-d*100-e*10;
g = X/100-a*1000000-b*100000-c*10000-d*1000-e*100-f*10;
h = X/10-a*10000000-b*1000000-c*100000-d*10000-e*1000-f*100-g*10;
i = X/1-a*100000000-b*10000000-c*1000000-d*100000-e*10000-f*1000-g*100-h*10;
y = b + c + d + e + f + g + h; if( ( a % i ) == 0 & ( y / 2 ) == 1 )
JOptionPane.showMessageDialog(null,"Congratulation, your student ID number is valid" );
else
JOptionPane.showMessageDialog(null," Sorry, your student ID number is not valid " );
}
}
import javax.swing.*;public class good1 {
public static void main(String args[])
{
String inputString;
int a, b, c, d, e, f, g, h, i, j, X, x, y; inputString = JOptionPane.showInputDialog("Enter Student ID number" );
X = Integer.parseInt(inputString);
a = X/100000000;
b = X/10000000-a*10;
c = X/1000000-a*100-b*10;
d = X/100000-a*1000-b*100-c*10;
e = X/10000-a*10000-b*1000-c*100-d*10;
f = X/1000-a*100000-b*10000-c*1000-d*100-e*10;
g = X/100-a*1000000-b*100000-c*10000-d*1000-e*100-f*10;
h = X/10-a*10000000-b*1000000-c*100000-d*10000-e*1000-f*100-g*10;
i = X/1-a*100000000-b*10000000-c*1000000-d*100000-e*10000-f*1000-g*100-h*10;
y = b + c + d + e + f + g + h; if( ( a % i ) == 0 & ( y / 2 ) == 1 )
JOptionPane.showMessageDialog(null,"Congratulation, your student ID number is valid" );
else
JOptionPane.showMessageDialog(null," Sorry, your student ID number is not valid " );
}
}
解决方案 »
- java 远程通信
- 请问jtable中单元格点击怎么弹出日期控件和下拉列表
- java键盘事件
- hibernate中怎么做select 1表.name,2表.age into 新表 from 1表,2表 ?
- 拜求指点(文件处理)
- 一个关于JavaDOC同时支持多种语言问题,估计这个问题是没有解的...
- 大虾帮忙!编译时提示这样的错误是为什么?
- 使用100%的Java代码可不可以编写对系统硬件进行操作(即直接驱动硬件)的代码啊?比如说直接读写I/O数据,直接进行文件的读写???
- 请好心人帮忙,先谢谢了。关于使用ultraedit后的TXT乱码问题。
- Math.round(14.8)是等于15.0,还是15
- 怎么从文件里读中文?
- 自己做的新的类文件怎么在环境变量中设置阿?
String X = inputString;
a = Integer.parseInt(X.substring.(0,1));
b = Integer.parseInt(X.substring.(1,2));
c = Integer.parseInt(X.substring.(2,3));
d = Integer.parseInt(X.substring.(3,4));
e = Integer.parseInt(X.substring.(4,5));
f = Integer.parseInt(X.substring.(5,6));
g = Integer.parseInt(X.substring.(6,7));
h = Integer.parseInt(X.substring.(7));
public static void main(String args[])
{
String inputString;
int a, b, c, d, e, f, g, h, i, j, x, y; inputString = JOptionPane.showInputDialog("Enter Student ID number" );
String X = inputString;
a = Integer.parseInt(X.substring.(0,1));
b = Integer.parseInt(X.substring.(1,2));
c = Integer.parseInt(X.substring.(2,3));
d = Integer.parseInt(X.substring.(3,4));
e = Integer.parseInt(X.substring.(4,5));
f = Integer.parseInt(X.substring.(5,6));
g = Integer.parseInt(X.substring.(6,7));
h = Integer.parseInt(X.substring.(7,8));
i = Integer.parseInt(X.substring.(7,8));
y = b + c + d + e + f + g + h; if( ( a % i ) == 0 && ( y / 2 ) == 1 )
JOptionPane.showMessageDialog(null,"Congratulation, your student ID number is valid" );
else
JOptionPane.showMessageDialog(null," Sorry, your student ID number is not valid " );
}
}