import java.util.Scanner;
class Demo07_Pratice {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=(int) (Math.random()*100+1);
for (int a=1; a<=5;a++ ) {
System.out.println("请输入你要判断的数:");
int g=sc.nextInt();
if (g>n) {
System.out.println("对不起,你输入的数大了");
} else if (n<g) {
System.out.println("对不起,你输入的数小了");
} else {
System.out.println("恭喜你,猜对了!");
break;
}
}
System.out.println("对不起,你的5次机会已用完。欢迎下次再玩!");
}
} |
|