Question: Create an object and use it with the number guessing game in Java. I am just about done with this assignment, however, I need to

Create an object and use it with the number guessing game in Java.

I am just about done with this assignment, however, I need to use an object to count the number of tries it takes the user and for some reason it keeps it at 1 instead of increasing. Here is my code so far.

Main Class:

Create an object and use it with the number guessing game in

NumberGame class:

Java. I am just about done with this assignment, however, I need

ch04 ex4_GuessingGame - NetBeans IDE 8.2 File Edit View Navigate Source Refactor Run Debug Profile Team Tools Window Help | Projects X -Start Page x|ES9Mainjava x st NumberGamejava x ch04_ex4_GuessingGame Source Packages ?.fi package murach.games: murachgames Main.java NumberGame.java import java.util.Random; import java.util.Scanner; Libraries 5 public class Main public static void main (String args[]) i System.out.println("Welcome to the Number Guessing Game") System.out.println ); 10 Scanner sc new Scanner (System. in); int upperLimit -50 // Get upper limit removed System.out.print ("The upper limit is:" upperLimit "In") NumberGame object new NumberGame (upperLimit) System.out.println("OK, I'm thinking of a number between 0 and "+ 12 13 14 15 16 17 18 19 20 21 object.getUpperLimit )) System.out.println ) // Generate a random number between O and the upperLimit variable Random random - new Random ); int number = randon.nextInt(upperLimit - 1) + 1; 23 24 25 26 27 28 29 30 31 32 int count 1; System.out.print ("Enter your guess: "); int guessInteger.parseInt (sc.nextLine )); while (guess !- number) object.incrementGuessCount ) if (guessnumber) System.out.println ("Your guess is too high.In") 35 36 System.out.print ("Enter your guess: "); guessInteger.parseInt (sc.nextLine ()) System.out.println ("Correct!n") System.out.println("You gessed the correct number in"+ count + System.out.println("Bye!"): 38 39 "guesses. "); & > ? main ? Output ch04_ex4 GuessingGame (run) X Your guess is too high murach.games.Main Type here to search

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!