Simple iteration and Branch Statement problem
Hi
I am having trouble with the code below which seems to be doing nothing after thefor(int i = 0; i < numberOfRecords; i++ ):
publicstaticvoid sellItems()
{
String itemCode;
Item temp =null;
boolean valid =false;
double amount = 0.0;
System.out.println();
System.out.println("******** Sell item screen ********");
System.out.println();
System.out.print("Enter code for the item to be sold: ");
do
{
itemCode = console.nextLine();
temp =null;
[b]for(int i = 0; i < numberOfRecords; i++ )[/b]
{
if(items[i].getItemCode().equalsIgnoreCase(itemCode))
{
if(items[i]instanceof Fruit)
{
temp = items[i];
System.out.println("Please enter the amount of " +
temp +" you wish to sell");
amount = Double.parseDouble(console.nextLine());
}
elseif(items[i]instanceof Vegetable)
{
temp = items[i];
System.out.println("Please enter the amount of " +
temp +" you wish to sell");
}
}
}
if (temp ==null)
{
System.out.println("Error, item code " + itemCode +
" was not found!");
}
else
{
valid =true;
}
}while (valid !=false);
}
Is anybody able to give me a pointer on why this is happening?
Cheers
CC

