Question: Create a program that will randomly pick an integer less than 100 (do NOT tell the user what number is picked!) You will need the

Create a program that will randomly pick an integer less than 100 (do NOT tell the user what number is picked!)


 You will need the following code to generate the random integer:


 Random r = new Random();


 
 int number = r.nextInt(100); //number is now a random int less than 100


 
Give the user 10 guesses to see if they can pick the right number.  
FOR MAX 2 MARKS you should 
-     Ask the user a maximum of 10 times.  
-     If they guess the correct number, output "You win" 
-     If they run out of chances, output "Hard luck!".

Step by Step Solution

3.45 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public static void mainString args Random r new Random int number ... View full answer

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 Programming Questions!