谁会用JAVA把这个系统代码打出来x'x
2个回答
展开全部
public class baidu5 {
static int i1;
public static void main(String[] args) {
newRandom();
checkPrize(i1);
}
static void newRandom() {
Random random = new Random();
//生成中奖随机数
i1 = random.nextInt(9) % 8;
System.out.println("中奖号码是:" + i1);
}
static void checkPrize(int i) {
int j;
String s1;
System.out.println("请输入四位会员号:");
Scanner scanner = new Scanner(System.in);
s1 = scanner.next();
//计算百位和十位的差值绝对值
j = Math.abs(s1.charAt(1) - s1.charAt(2));
if (j == i) {
System.out.println("恭喜!你中奖了!");
} else {
System.out.println("很遗憾!你没有中奖!");
}
again();
}
static void again() {
System.out.println("是否继续?(y/n)");
Scanner scanner = new Scanner(System.in);
String s2;
s2 = scanner.next();
if (s2.equals("y")) {
checkPrize(i1);
} else {
System.out.println("程序结束!");
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询