package study; import java.util.Scanner; /**
* 猜数字小游戏
*
* @author carry
*
*/
public class GuessNumberDemo {
public static void main(String[] args) {
int number = (int) (Math.random() * 100) + 1;
System.out.println(number);
while (true) {
//System.out.println("请输入您猜到的数字:");
@SuppressWarnings("resource")
String line = new Scanner(System.in).nextLine();
int value = Integer.parseInt(line);
if (number > value) {
System.out.println("您猜小了");
}
if (number == value) {
System.out.println("您猜对了");
break;
}
if (number < value) {
System.out.println("您猜大了");
}
}
}
}