Alright, I am trying to write this code but I keep getting this stupid error. I have no idea what I am doing wrong so maybe one of you experts can help me out.
import java.util.*;
public class School
{
Random randQuest = new Random();
int userAnswer;
public void createQuestion()
{
int range = 10; // range of numbers in question
int num1 = randQuest.nextInt( range );
int num2 = randQuest.nextInt( range );
userAnswer = num1 * num2;
System.out.printf( "How much is %d times %d?\n",
num1, num2 );
}
// prompt comment
public String promComm( boolean answer )
{
if ( answer )
{
switch ( randQuest.nextInt( 1 ) )
{
case 0:
return( "Very Good!" );
}
switch ( randQuest.nextInt( 1 ) )
{
case 0:
return( "No. Please try again." );
}
}
}
}
In method
promCommifanswerisfalsethe method does not return any value.Same if
randQuest.nextInt(1) != 0.Should be something like :