Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java language Java language Your program will choose a random 4 digit number as the secret number. Your program must prompt the user to enter

Java languageimage text in transcribedJava language

Your program will choose a random 4 digit number as the secret number. Your program must prompt the user to enter a 4 digit number as their guess. The program will respond with a message indicating how many of the digits in the user's guess are the same as the digit in the same position in the secret number. For example, if the secret number is 3749, and the user's guess is 9753, then the program would respond with the message You matched 1, because only one of the digits (the 7) in the user's guess is the same as the digits in the same position in the secret number. The program will allow the user to continue to enter guesses until they guess the correct secret number. After the user has entered the secret number, the program will output a count of the total number of guesses the user took to find the secret number. Then the program will ask the user if they would like to play again. If the user answers "yes", then the program will choose another random 4 digit number and play continues as described above. Here's an example interaction (user input in bold): MASTERMIND Guess the 4 digit number! Guess 1: 0000 You matched 0 Guess 2: 1111 You matched 1 Guess 3: 1234 You matched 1 Guess 4: 2444 You matched 2 Guess 5: 1442 You matched 4 Congratulations! You guessed the right number in 5 guesses. Would you like to play again (yes/no)?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Global Strategy

Authors: Mike W. Peng

5th Edition

0357512367, 978-0357512364

Students also viewed these Programming questions

Question

Illustrate the systems approach of family therapy.

Answered: 1 week ago

Question

Absence of disparate impact

Answered: 1 week ago

Question

Performance appraisal criteria based on job analysis

Answered: 1 week ago

Question

Focus on clients needs (efforts to fulfi ll clients requirements)

Answered: 1 week ago