代码如下:
package homw;
import java.util.*;
public class capitol_method {
Scanner input = new Scanner(System.in);
int done = 0;
int wrong = 0;
int correct = 0;
String[][] spc = {
{"MONTGOMERY","AlABAMA"},
{"JUNEAU","ALASKA"}
};
public void guess (){
for (int i=0; i<50; i++){
while (done == 0 && i<50){
String capitol = input.next();
String upp2 = capitol.toUpperCase();
if (!spc[i][1].equals(upp2)){
wrong = wrong + 1;
}else{
correct = correct + 1;
}
System.out.println("wong"+wrong);
System.out.println("correct"+correct);
System.out.println("spc"+spc[i][1]);
}
}
}
}
debug 返回的 spc 和输入的一摸一样。但是 wrong 变量的数值却在增加。
1
hx1997 2016-02-17 23:16:34 +08:00
ALABAMA not AlABAMA maybe?
|
3
yuriko 2016-02-18 17:15:33 +08:00
写 Java 我好久不用数组了……
|