Java代码求助
程序代码:
class NumberGuess{ public static void main(String []args) throws Exception { int random = (int)(Math.random()*11); //产生10以内的随机数 int num=0; int times = 0; int ch = 0; boolean isEnd = false; //游戏开关 System.out.println("Please Input A Number:"); while(true){ ch = System.in.read(); switch(ch){ //进行判断 case '\r': break; case '\n': num/=10; System.out.println("Your number is "+num); System.out.println("The number is "+random); if(num>random){ System.out.println("Guess larger!"); times++; } if(num<random){ System.out.println("Guess smaller!"); times++; } if(num==random&×<4){ System.out.println("Yes! You are right!"); isEnd = true; } if(ch!=random&×==4){ System.out.println("Sorry!The number is "+random); isEnd = true; } if(isEnd){ random = (int)(Math.random()*11); isEnd = false; times=0; } num=0; break; default: num+=(ch-'0'); num*=10; } } } }这段代码是 猜数字游戏,哪里出现问题了。。。多次执行后就成了10,不再得到随机数,而且输入10 还不正确。