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. Guesser should open a Scan

ID: 3619198 • Letter: W

Question

Write a new program Guesser, save it as Guesser.java. Guesser should open a Scanner on the keyboard, call it input. Guesser should define a public static final int secretNumber with class scope and set to a number between 1 and 100. The program should print "guesser begins...". Compile and test the program so far. Create a method getGuess that, given a Scanner variable input, prompts the user to guess a number between 1 and 100, and returns the 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 too high, and "WINNER" if the guess is correct. The method should return false if it is high or low, and true if the guess is correct. Test this method for all legal inputs. (Note this method has the effect of resolving to true or false) Implement the following logic using your methods set guesses to 7 // 7 chances to guess this secretNumber set guessNumber to getGuess(input); // guess this number by keyboard input while ((! winner (guessNumber)) && (guesses > 0)) // haven't got the correct number, and still have chances left print you have --guesses left getGuess(input) If guesses

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"); int guessNumber,guesses=7; guessNumber=getGuess(input); while ( (guesses > 0) &&(! winner (guessNumber))) { guesses--;       System.out.println("You have "+guesses+"guesses left");       if(guesses>0)             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