Question
The guessing game program will use the (int) (Math.random()*9)+1 to generate five numbers between 0 to 9, storing those numbers in a single String. The
The guessing game program will use the (int) (Math.random()*9)+1 to generate five numbers between 0 to 9, storing those numbers in a single String. The player then tries to guess the number. With each guess the program returns two numbers, the first is the number of correct digits that are in the proper position and the second number is the sum of the correct digits. When the user enters the correct five-digit number the program returns a statement that tells them that the user found the correct number, and how many tries it took the user to find the number. Allow the user to repeat the game as many times as they wish without leaving the game. Guarantee the numbers entered are 5 digit numbers. You must use at least 3 separate methods in the game. 1) The game setup, this includes the setting of all variables and building a new 5 digit number. 2) The top-level control logic of the game. 3) Menu printing and retrieving user input.
No Arrays
Please write code in java
All in one class
3 different methods that do as stated above
make sure only 5 digits can be entered
Example Output:
Welcome to the Mastermind Number Game!
Your job is to guess the digits of a 5 digit number.
There is a new 5 digit number for you to find.
Please enter your guess.
02473
You have found 2 digits in the correct position, with a sum of 4.
Please enter your guess.
08459
You have found 3 digits in the correct position, with a sum of 13.
Please enter your guess.
06439
You have found 4 digits in the correct position, with a sum of 19.
Please enter your guess.
06429
Congratulations. 06429 is correct!
It took 4 guesses to get the number.
Would you like to play the game again?
Please enter (yes/no) maybe
Please enter (yes/no) yes
There is a new 5 digit number for you to find.
Please enter your guess.
00000
You have found 1 digits in the correct position, with a sum of 0.
Please enter your guess.
01111
You have found 3 digits in the correct position, with a sum of 2.
Please enter your guess.
01122
You have found 1 digits in the correct position, with a sum of 0.
Please enter your guess.
02211
Congratulations. 02211 is correct!
It took 4 guesses to get the number.
Would you like to play the game again?
Please enter (yes/no) no
Thank you for playing the Mastermind Number Game!
Step by Step Solution
3.36 Rating (165 Votes )
There are 3 Steps involved in it
Step: 1
Python code for the mastermind game import random printWelcome to the Mastermind number game randrange function generates a random number within the s...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started