问题是要求我掷两个骰子并在两个单独的列中分别打印它们的输出,然后为两次掷骰的总和创建第三列。
import java.util.Random;
public class DiceRolls {
public static void main(String[] args) {
System.out.println("Dice 1\tDice 2");
Random ran = new Random();
int numberOne;
for (int x = 0; x < 7; x++) {
numberOne = ran.nextInt(6) + 1;
System.out.println(numberOne);
}
int numberTwo;
for (int y = 0; y < 7; y++) {
numberTwo = ran.nextInt(6) + 1;
System.out.println(" " + numberTwo);
}
}
}
呼啦一阵风
相关分类