/*
* 需求:猜数字小游戏(数据在1-100之间) 对于次数进行计数并且对次数进行评价
*/
import java.util.Scanner;
class Test_Math {
public static void main(String[] args) {
int count = 0;
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个1-100的整数");
int x = (int)(Math.random() * 100) + 1;
while (true) {
int y =sc. nextInt();
count++;
if (y > x ) {
System.out.println("大了");
}
else if (y < x ) {
System.out.println("小了");
}
else{
System.out.println("中了");
if (count < 5) {
System.out.println("牛逼");
}
else if (count >= 5 && count <= 8) {
System.out.println("就那样");
}else{
System.out.println("菜鸟");
}
break;
}
}
System.out.println(count);
}
}
|
|