i get this 'else' without 'if' error on this case:
case 2:
for(int i=0;i<currentRegisterdItems;i++){
System.out.println("#"+i+" - "+itemArray[i] + "\t\t\t" + priceArray[i]);
System.out.println("Select products and add to cart - Simple Shop Software");
System.out.println("Enter the product id: ");
int searchIdProduct = Integer.parseInt(a.readLine());
if(itemArray[searchIdProduct] != null){
System.out.println("Add "+itemArray[searchIdProduct]+" to your cart?");
System.out.println("Confirm: Y Cancel: N");
char confirmFlag = a.readLine().charAt(0);
if(confirmFlag == 'y'){
System.out.println("How many "+itemArray[searchIdProduct]+" do you want?");
int amountProduct = Integer.parseInt(a.readLine());
System.out.println("Confirm: Y Cancel: N");
char confirmFlag1 = a.readLine().charAt(0);
if(confirmFlag1 == 'y')
{
if(amountProduct >= 1)
{
double subTotalCost = priceArray[searchIdProduct] * amountProduct;
quantityCartArray[opCounter] = amountProduct;
cartArray[opCounter] = itemArray[searchIdProduct];
subtotalCartArray[opCounter] = subTotalCost;
System.out.println("Subtotal: "+df.format(subTotalCost));
totalCost += subTotalCost;
opCounter++;
}
}
}
}
}else{
System.out.println("ERROR! - Product ID doesnt exist... to main menu");
}
break;
can you tell me what is wrong that causes 'else' without 'if' error to show..