Question: Write a Java program that has a user guess a secret number between 1 and 1 0 . Store the secret number in a variable

Write a Java program that has a user guess a secret number between 1 and 10.
Store the secret number in a variable called secretNumber and allow the user to continually input numbers until they correctly guess what secretinumber is.
Complete the method guessmynumber that uses a while loop to ask the user for their guess and compares it againist secretNumber.
For example, if secretnumber was 6, an example run of the program may look like this:
I'm thinking of a number between 1 and 10.
see if you can guess the number!
Enter your guess:
4
Try again!
Enter your guess:
3
Try again!
Enter your guess:
1
Try again!
Enter your guess:
10
Try again!
Enter your guess:
6
correct!
Note: In order to pass the grader, you must set the secretNumber to 6.
 Write a Java program that has a user guess a secret

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!