Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

=+(3.14) Q((HOA) U (HenB)) = P(HOA) +P (H'nB) for A, B E 70.

Answered: 1 week ago

Question

When should you avoid using exhaust brake select all that apply

Answered: 1 week ago