SOLVED! Figured it out last night but it works perfectly. I want to thank all who helped me. Feel free to test it out for yourselves
import javax.swing.*;
public class Homework4a {
public static void main(String[] args) {
int[] numarray = new int [10];
for ( int i = 0 ; i < numarray.length ; i++ ) {
numarray[i] = (int) (Math.random() * 100 + 1);
}
System.out.println("The random numbers are: "+ java.util.Arrays.toString(numarray));
int userinput = Integer.parseInt(JOptionPane.showInputDialog ( "Guess a number between 1 and 100" ));
while ( userinput > 100 || userinput < 1 ) {
JOptionPane.showMessageDialog(null, "Your number wasn't in the parameters" );
userinput = Integer.parseInt(JOptionPane.showInputDialog ( "Guess a number between 1 and 100" ));
}
for ( int j = 0 ; j < numarray.length ; j++ ) {
if ( numarray[j] != userinput ) {
}
else {
JOptionPane.showMessageDialog(null, "WINNER!!!!\n\nYou guessed the number! Thanks for playing " + "\nThe number is stored at position " + j );
return;
}
}
JOptionPane.showMessageDialog(null, "The answer is not in correct" );
}
}