Original Post
hey there, im trying to write a simple java selection method. If the value the user enters doesnt any of the values in the array, it loops until a valid one is entered. However it states a value is invalid even if the value is valid!
The code is below
int[] array = {1,2,3};
int selection = 0;
//selection method, this is the bit causing the trouble
screen.println("please select a number, 1, 2 or 3");
selection = new Integer(keyboard.readLine()).intValue();
screen.println("selection : "+selection);
if (selection != array[0] || selection != array[1] || selection != array [2])
{
do
{
screen.println("Invalid selection, please enter the correct one");
selection = new Integer(keyboard.readLine()).intValue();
}
while(selection != array[0] || selection != array[1] || selection != array[2])
}
Any Suggestions are VERY much appreciated
[edited by - Paul R on April 30, 2003 7:11:47 PM]
[edited by - Paul R on April 30, 2003 7:12:50 PM]