rendered paste bodyimport java.util.Scanner;import java.util.Random;public class GuessingGame { private int limit; private Random rndGen; private Scanner reader; public GuessingGame(int limit, long seed) { this.limit = limit; rndGen = new Random(seed); reader = new Scanner(System.in); } public int playGame() { System.out.println("I'm thinking of a number between 1 and " + limit + " ...\n"); int num = rndGen.nextInt(limit); int guess = -1; int cnt = 0; do { System.out.print("Your guess? "); // prompt the user guess = reader.nextInt(); cnt++; if (guess > num) { System.out.println("It's lower."); } else { System.out.println("It's higher."); } } while (guess != num); System.out.println("You guessed it in " + cnt + " guesses!"); return cnt; } public void start() { boolean play = true; String again = ""; int bestGame = 0; int gamesPlayed = 0; int totalGuesses = 0; do { int tries = playGame(); gamesPlayed++; totalGuesses += tries; if (tries < bestGame) { tries = bestGame; } System.out.print("Play again? "); again = reader.next(); } while (again != null && again.toLowerCase().startsWith("y")); System.out.println("\nYour overall results:"); System.out.println("Total games = " + gamesPlayed); System.out.println("Total guesses = " + totalGuesses); System.out.println("Guesses/game = " + ((double)totalGuesses)/gamesPlayed); System.out.println("Best game = " + bestGame); } public static void main(String[] args) { String haiku = "This is a poem.\nI don't know haikus. Watermelon."; System.out.println(haiku); GuessingGame game = new GuessingGame(100, 0); game.start(); }}