Question: package numberguess; public class NumberGuess { public static void main(String[]args){ // Define program variables int randNum, guessNum, attemptNum; // Generate a random number between 1

package numberguess;

public class NumberGuess {

public static void main(String[]args){

// Define program variables

int randNum, guessNum, attemptNum;

// Generate a random number between 1 and 10

randNum = new

java.util.Random().nextInt(10) + 1;

// Display a message

System.out.println

("I am thinking of a random number between 1 and 10");

// Ask for a guess and check the input

for ( attemptNum = 1; attemptNum <= 3; attemptNum++ )

System.out.print("Guess what it is?");

java.util.Scanner scan = new

java.util.Scanner(System.in);

guessNum = scan.nextInt();

System.out.println("You guessed " + guessNum);

if ( randNum == guessNum )

System.out.println("You guessed it!");

break;

}

System.out.println("Sorry, try again!");

}

"Exception in thread "main" java.lang.Error: Unresolved compilation problem:

at NumberGuess/numberguess.NumberGuess.main(NumberGuess.java:3)"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!