Question: Java sourse code for rng number guessing: import java.util.Random; import java.util.Scanner; public class Lab6B { public static void main(String[] args) { Random random = new

Java sourse code for rng number guessing: import java.util.Random; import java.util.Scanner; public class Lab6B { public static void main(String[] args) { Random random = new Random(); Scanner scnr = new Scanner(System.in); System.out.print("Enter a number between 1 and 1000: "); int userInput = scnr.nextInt(); while (userInput  1000) { System.out.print("Enter a number between 1 and 1000: "); userInput = scnr.nextInt(); } int compGuess = random.nextInt(1000) + 1; int numGuesses = 1; while (userInput != compGuess) { compGuess = random.nextInt(1000) + 1; numGuesses++; System.out.println("My guess was " + compGuess); } System.out.println(" I guessed the number was " + compGuess + " and it only took me " + numGuesses + " guesses"); } }

This is what I got from the autograder and not sure what that Expected : 1000 is coming from Java sourse code for rng number guessing: import java.util.Random; import java.util.Scanner; public 

My guess was 138 My guess was 914 My guess was 23 I guessed the number was 23 and it only took me 505 guesses Expected : 1000

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!