package com.derun;
import java.util.Scanner;
class Game {
public static void main(String[] args) {
int sj = (int) (Math.random() * 100);
boolean flag2 = true;
while (flag2) {
System.out.println("请输入数字:");
boolean flag = true;
while (flag) {
Scanner sc = new Scanner(System.in);
int sz = sc.nextInt();
if (sz < sj) {
System.out.println("不好意思,您输入的数字太小了,加油,亲!");
} else if (sz > sj) {
System.out.println("不好意思,您输入的数字太大了,加油,亲!");
} else {
System.out.println("恭喜您猜对了,奖励香吻本人一枚!");
flag = false;
}
}
System.out.println("请输出对应的操作:0-继续游戏 1-退出游戏");
boolean ab = true;
while (ab) {
Scanner sc = new Scanner(System.in);
String jx = sc.nextLine();
switch (jx) {
case "1":
System.out.println("你已经成功退出游戏");
System.exit(0);
break;
case "0":
System.out.println("你已经成功重新进入游戏");
ab = false;
break;
default:
System.out.println("请输入正确的格式");
break;
}
}
}
}
}
import java.util.Scanner;
class Game {
public static void main(String[] args) {
int sj = (int) (Math.random() * 100);
boolean flag2 = true;
while (flag2) {
System.out.println("请输入数字:");
boolean flag = true;
while (flag) {
Scanner sc = new Scanner(System.in);
int sz = sc.nextInt();
if (sz < sj) {
System.out.println("不好意思,您输入的数字太小了,加油,亲!");
} else if (sz > sj) {
System.out.println("不好意思,您输入的数字太大了,加油,亲!");
} else {
System.out.println("恭喜您猜对了,奖励香吻本人一枚!");
flag = false;
}
}
System.out.println("请输出对应的操作:0-继续游戏 1-退出游戏");
boolean ab = true;
while (ab) {
Scanner sc = new Scanner(System.in);
String jx = sc.nextLine();
switch (jx) {
case "1":
System.out.println("你已经成功退出游戏");
System.exit(0);
break;
case "0":
System.out.println("你已经成功重新进入游戏");
ab = false;
break;
default:
System.out.println("请输入正确的格式");
break;
}
}
}
}
}