
I have got this code but am not totally understanding what the errors. Could someone Please help. Thanks in advance!
import java.util.Random; import java.util.Scanner; private static int nextInt() {
public class MatchingPair{ private static class input {
private static int nextInt() {
throw new UnsupportedOperationException("Not yet implemented");
}
Scanner sc = new Scanner(System.in);
int randomNumber = new Random().nextInt(100) + 1; // this is wrong it should be like this: int randomNumber = (int) (Math.random() * 100 + 1); close though.
System.out.print("Enter number to guess: ");
int num=input.nextInt();
while(num!=randomNumber){
if (num>randomNumber){
System.out.println("Guess lower!"); // this says to guess lower
}
else if (num<randomNumber);
System.out.println("Guess higher!"); // this says to guess higher
System.out.print("Wrong! Again Guess: "); // this doesn't need to be here
num=input.nextInt();
}
if (num==randomNumber){
System.out.println("Correct!!!!!!!");
}
}
}

import java.util.Random;
import java.util.Scanner;
public class MatchingPair{
public static void main(String[]args){
Scanner input = new Scanner(System.in);
int randomNumber = new Random().nextInt(100) + 1; // this is wrong it should be like this: int randomNumber = (int) (Math.random() * 100 + 1); close though.
System.out.print("Enter number to guess: ");
int num=input.nextInt();
while(num!=randomNumber){
if (num>randomNumber){
System.out.print("Guess lower! : "); // this says to guess lower
num=input.nextInt();
}
if (num<randomNumber){
System.out.print("Guess higher! : "); // this says to guess higher
num=input.nextInt();
}
if (num==randomNumber){
System.out.println("Correct!!!!!!!");
}
}
}
}