Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Write a 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 secretNumber 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.

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

Database Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions