Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

what i have so far that isn't working CM10 Principles 100 Assignment 04-Master Mind You must work in alone on this assignment. Do not use

image text in transcribed
what i have so far that isn't working
image text in transcribed
CM10 Principles 100 Assignment 04-Master Mind You must work in alone on this assignment. Do not use any lava language features we have not cover so far in this course Assignment Objectives After completing this assignment the student should be able to: Write programs that use loops to repeat instruction Demonstrate the use of while or for loops in Java Use conditional expression to control loops and decisions Assignment Requirements For this signment you are given the following tiles Assignment04.java Iyou must complete this file Problem Description and Given Info Within the main method in the Assignmento java file, you must write a program to pame of Master Mind with the user Your program will choose a random 4 digit number as the secret number. Your program most promote user to enter a 4 dit number as their guess. The program will respond with a message indicating how many of the gas in the user's guess are the same as the digit in the same position in the secret number. For example, the secretumber is 145, 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 wil 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 ser if they would like to play again the ser answers "yesthen the program will choose another random 4 digit number and play continues as described above Here's an example interaction fuser input in bold MASTERMIND Guess the 4 digit number Guess 1: 0000 You matched Guess 2: 1111 You watched 1 Guess 3: 1234 You watched 1 Guess 4: 2444 You matched 2 Guess 5: 1442 You watched 4 Congratulations! You guessed the right number in 5 guesses. Mould you like to play again (yeso)? Program Pendocode Template You may other plate of you find the while the user wants to play another Pick a new secret number While the user's guess is not completely correct Prompt the user to make a gess do 5 import java.util.Scanner; 6 import java.util. Random; 7 8 public class Assignment4 { 99 public static void main(System[] args) { 10 Scanner scan - new Scanner (system.in); 12 12 //variables 13 int guesscount, match; 14 String userGuess, answer; 15 String option "yes", 16 17 18 19 guessCount = 0; 20 Random generator - new Randon(); 21 answer string.valueof(generator.nextInt(9998)+1000); 22 //start loop 23 do 24 { 25 match 26 System.out.println("..---MASTERMIND ----"); 27 System.out.println("Guess the 4 digit number!"); 28 userGuess - scan.next(); 29 guessCount++; 30 System.out.println("Guess " + puesscount":"userGuess): 31 12 for (int i=0; i

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 And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions