import java.util.Random;
import java.util.Scanner;
public class Ex6Qus33
{
Random randomNumbers = new Random(10);
public int guessNumber()
{
int numberGuess = 1 + randomNumbers.nextInt(1000);
return numberGuess;
}
public void playNumber()
{
String a = "Yes";
String b = "No";
randomNumbers.setSeed(10);
Scanner input = new Scanner(System.in);
System.out.print("Guess a number between 1 and 1000:- ");
int player = input.nextInt();
guessNumber();
while(player != guessNumber())
{
if(player < guessNumber())
{
System.out.println("Too Low. Try again!!!");
System.out.print("Guess a number between 1 and 1000:- ");
player = input.nextInt();
}
else
if(player > guessNumber())
{
System.out.println("Too High. Try again!!!");
System.out.print("Guess a number between 1 and 1000:- ");
player = input.nextInt();
}
}
System.out.println("Congratulations. You guessed the number.!!!");
System.out.println("Do wish to play again?");
String play = input.nextLine();
if(play.equals(a))
guessNumber();
else
if(play.equals(b))
System.out.println("End of Game");
}
public static void main(String args[])
{
Ex6Qus33 apps = new Ex6Qus33();
apps.playNumber();
}
}