我编写了以下代码,询问“num1 乘以 num2 是多少?”这个问题。但是,当我尝试运行 java 文件时,我没有得到任何响应。你能帮我理解我做错了什么吗?代码如下:
import java.util.Scanner;
import java.util.Random;
public class MultiplyLearn{
public void Learn(){
Random multiple = new Random();
Scanner input = new Scanner( System.in );
boolean wrong = true;
int num1 = 1 + multiple.nextInt( 9 );
int num2 = 1 + multiple.nextInt( 9 );
while( wrong == true ){
askQuestion( num1, num2 );
int answer = input.nextInt();
if( answer == num1*num2 ){
System.out.println( "Very Good" );
wrong = false;
}
else{
System.out.print( "No. Please try again." );
}
}
}
public String askQuestion( int x, int y ){
return "How much is" + x + "times" + y + "?";
}
}