Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CPT 236 Programming Project 4 Project 4: Chapter 5 - Using Prebuilt Methods Problem Definition: Write an interactive game program that counts how many guesses
CPT 236 Programming Project 4 Project 4: Chapter 5 - Using Prebuilt Methods Problem Definition: Write an interactive game program that counts how many guesses a player takes to discover a secret random number, between 1 and 10, chosen by the computer. The program should use the Math.random() method to generate the secret number then repeatedly query the player to enter a starting or follow-up guess. Depending on the comparison of the secret number and the players guess, the game should do one of the following: If the players guess is greater than the secret number Print "Your guess is greater than the secret number, choose again If the players guess is less than the secret number o Print Your guess is less than the secret number, choose again If the players guess is equal to the secret number Print Congratulations you have guessed the secret number!" Depending on the rules above, the program should either again ask for a follow-up guess (if the player chose incorrectly) or print the final number of guesses the player took to find the secret number and quit (if the player chose correctly). Be sure and use Math.random() correctly in order to generate an integer between 1 and 10; the random method generates a decimal number between 0.0 and 1.0. Use an appropriate loop to repeatedly ask for follow-up guesses by the player. Instructions: Write and submit the Java code that correctly represents a solution to the problem presented above. What to turn in: Go to the D2L class page, select Assignments then click on Programming Project 4. You will then submit your Java code (it is the file that ends in java in the src folder) using the "Add a File" and Submit buttons. I will examine the source file and grade based on
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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