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

I need to make a guessing game in java. the user enters the lowvalue and high va

ID: 3617561 • Letter: I

Question

I need to make a guessing game in java. the user enters the lowvalue and high value and program needs to generate a random numberin between. the user also enters number of guesses they want. theuser than enters their guess and the output must say if they areright or wrong and how many guesses they have left. if they losethey are asked if they want to play again.


Explanation / Answer

please rate - thanks import java.util.*; public class guessingGame2 {         public static voidmain(String [] args) {            int number;            int guess;            int guesses;            int over,low,high;            char torf='y';               Scanner Keyboard=newScanner(System.in);        do {               System.out.println("Enter low number:");               low=Keyboard.nextInt();            System.out.println("Enter high number: ");               high=Keyboard.nextInt();            System.out.println("Enter number of guesses: ");               guesses=Keyboard.nextInt();                    int num=(int)(100 * Math.random ())%(high-low+1)+low;                    over=0;                    do {                             System.out.println("you have"+guesses+" guesses");                        System.out.println("Guess a number between "+low+" and "+high+":");                        guess=Keyboard.nextInt();                        guesses--;                        if (guessnum)                                  {                            System.out.println("Your guess is too high.");                           }                              else                                 {System.out.println("You got it! ");                                  over=1;                                    }                         }while(guesses>0&&over==0);    if(over==0)         { System.out.println("Thenumber was "+num);                                System.out.println("Would you like to play again (y/n)? ");        torf=Keyboard.next().charAt(0);           }    else          System.exit(0);     }while(torf=='y'||torf=='Y'); } }