I am making a number guessing game in Java, where the program displays a number, in a 1 to 10 range, and you have to either guess if the next number will be lower or higher than the current one. But there seems to be an issue when i get it correct i am supposed to get a point added to my score but instead it just does the method for when I get the guess wrong.
class csjava
{
public static void main(String[] args)
{
Random dom = new Random();
Random dom2 = new Random();
Scanner input = new Scanner(System.in);
int score = 0;
System.out.println("Guess if next number will be higher or lower Score:" + score);
int rnd = dom.nextInt();
int rnd2 = dom2.nextInt();
String lo = "lower";
String hi = "higher";
if(score ==10)
{
System.out.println("You win!");
}
while(score != 10)
{
System.out.println(dom.nextInt(10-1)+1);
String in = input.nextLine();
if(in == lo)
{
System.out.println(dom2.nextInt(10-1)+1);
if(rnd2 < rnd)
{
score = score + 1;
}
}
else
{
System.out.println("Nope, try again.");
}
if(in == hi)
{
System.out.println(dom2.nextInt(10-1)+1);
if(rnd2 > rnd)
{
score = score + 1 ;
}
else
{
System.out.println("Nope, try again.");
}
}
}
}