猜数字游戏 GuessNumber.java
import java.util.*;
public class GuessNumber{
//猜数字游戏
public static void main(String[] args){
Scanner in=new Scanner(System.in);
Random MyRandom=new Random();
int A=MyRandom.nextInt(101); //0~100
int number;
do {
System.out.println("请猜一下电脑随机生成的数是:");
number=in.nextInt();
if(number<A){
System.out.println("小了!");
}else if (number>A){
System.out.println("大了!");
}
}while(number!=A);
System.out.println("恭喜你猜对了!");
}
}