我想制作一个基本游戏,其中生成两个随机数,用户必须输入正确的产品.
我究竟做错了什么?谢谢
import java.util.Scanner;
import java.awt.*;
public class Userinput {
public static void main (String[] args) {
String firstName;
//Create scanner to obtain user input
Scanner scanner1 = new Scanner( System.in );
int a, b, correctAnswer;
a=(int) (Math.random()*10);
b=(int) (Math.random()*10);
//obtain user input
System.out.println("Enter your first name: ");
firstName = scanner1.nextLine();
//output information
System.out.print("Hello " + firstName + " ");
System.out.println("what is " + a +" times " + b);
String answer1 = scanner1.nextLine();
correctAnswer = a * b;
if …
Run Code Online (Sandbox Code Playgroud)