package javase24;
import java.util.Scanner;
public class GuessNumber {
public static void main(String[] args) {
int num =9;
Boolean guess= true;
while(guess) {
System.out.println("请输入一个数字");
Scanner user= new Scanner(System.in);
String Guess= user.nextLine();
//解析字符串成为数字
int userguess =Integer.parseInt(Guess);
//判断
if(userguess > 9){
System.out.println("你猜的数字太大了");
}else if(userguess < 9){
System.out.println("你猜的数字太小了");
}else{
System.out.println("恭喜你!猜对了");
guess=false;
}
//...........................
}
}
}
来源:https://blog.csdn.net/qq_25648915/article/details/100899543