Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a new program Guesser, save it as Guesser.java. Guessershould open a Scann

ID: 3619059 • Letter: W

Question

Write a new program Guesser, save it as Guesser.java. Guessershould open a Scanner on the keyboard, call it input. Guessershould define a public static final int secretNumber with classscope and set to a number between 1 and 100. The program shouldprint "guesser begins ...". Compile and test the program sofar.

Create a method getGuess that, given a Scanner variable input,prompts the user to guess a number between 1 and 100, and returnsthe guess number to the main. Test the method.

Create a method winner that, given the guess number, prints"higher" if the guess is too low, and "lower" if the guess is toohigh, and "WINNER" if the guess is correct. The method shouldreturn false if it is high or low, and true if the guess iscorrect. Test this method for all legal inputs. (Note this methodhas the effect of resolving to true or false)

Implement the following logic using your methods

set guesses to 7 // 7 chances to guess thissecretNumber

set guessNumber to getGuess(input); // guess this numberby keyboard input

while ((! winner (guessNumber)) && (guesses >0)) // haven't got the correct number, and still have chancesleft

print you have --guesses left

getGuess(input)

If guesses <= 0 print "you could have done better"
else print "CONGRATULATIONS !! YOU WON!"

Explanation / Answer

please rate - thanks import java.util.*; public class Guesser {public static final int secretNumber=17; public static void main(String[] args) {Scanner input=new Scanner(System.in); System.out.println("guesser begins guess a number"); int guessNumber,guesses=7; guessNumber=getGuess(input); while ((! winner (guessNumber)) && (guesses > 0)) //      {       System.out.println("You have "+guesses+"guesses left");       guesses--;       guessNumber=getGuess(input);        } if(guesses
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote