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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started