import java.util.Scanner;
import java.util.Random;
class GuessNumber2{
public static void main(String[] args){
Random r = new Random();
int number = r.nextInt(100)+1;
while(true){
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个数据:(1-100)");
int guessNumber = sc.nextInt();
if(guessNumber > number){
System.out.println("你输入的数据"+guessNumber+"大了!");
}
else if(guessNumber < number){
System.out.println("你输入的数据"+guessNumber+"小了!");
}
else{
System.out.println("你猜对了,请到田野处领取奖品!");
break;
}
}
}
}
|
|