我正在制作一个模拟器来查看随机数生成器需要多少次来“滚动”蛇眼。程序只是重复
Not snake eyes yet :(
这是代码:
import java.util.Random;
public class SnakeEyes {
public static void main(String[] args) {
Random myRandom = new Random();
int die1 = 0, tries = 0, die2 = 0;
System.out.println("Welcome to SEO (Snake Eyes Operator)!");
System.out.println("How many rolls will it take you to get to snake eyes! ");
die1 = myRandom.nextInt(6) + 1;
die2 = myRandom.nextInt(6) + 1;
while (die1 + die2 != 2) {
System.out.println("Not snake eyes yet :( ");
tries = +1;
}
System.out.print("You have rolled snake eyes! ");
System.out.print("Congratulations! It only took you ");
System.out.print(tries);
System.out.print("!");
}
}
我相信这是开环的问题,但我不确定。谢谢!