[英]Create constant for the maximum value the random number can be?
I want to create a simple Math game that uses two random numbers and then allows the user to input the answer for each of the following operations: (addition, subtraction, multiplication, and power). 我想创建一个使用两个随机数的简单数学游戏,然后允许用户输入以下每个操作的答案:(加,减,乘和乘)。 I don't know how to set the constant for a maximum a random number can be as a constant.
我不知道如何将最大随机数设置为常数。
import java.util.Random;
import java.util.Scanner;
public class Program1 {
public static void main(String[] args) {
Random generator = new Random();
// create a variable that will hold the first random number
int random1 = generator.nextInt();
// create a variable that will hold the second random number
int random2 = generator.nextInt();
// create a constant for the maximum the random number can be
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.