Ive been having some trouble with this assignment, its supposed to be kind of like a supermarket thing. I am new in java, the only import we are allowed to have if the scanner one.
The first time we record a customer and their items it works fine, it let me choose as many items as i want and of already existing in the array and everything runs smoothly - it goes on to ask if there´s any coupons and then it "prints" the receipt - the problem is the second customer - it all runs smoothly until this code (the one i´ll show below) it only lets me choose one product and the quantity and then it kind of moves to the next thing (ask for coupons and so on) and the third time it only let me choose the product - so i believe the problem is with the int.nextLine or something - i have looked at other questions and TRIED addind a nextLine or just next but it keeps happening so it might be the do while... i am not sure, i am new in java and in coding really - i will appreciate any kind of suggestion or input on it really.
do{
System.out.println("WHICH ITEM WOULD YOU LIKE TO BUY");
int CodeItem=input.nextInt();
//the array has max 20 items
if(CodeItem<=20 && CodeItem>=1){
if(item[CodeItem-1]!=("null") && price[CodeItem-1]!=0.0)
{
System.out.println("How many of:"+item[CodeItem-1]);
int CANT=input.nextInt();
LOCALamount[CodeItem-1]+=CANT;
GLOBALamount[CodeItem-1]+=CANT;
//the boolean ending is declared as true at the start of the code
}
else
{
System.out.println("****not valid****");
ending=false;
}}else
{
System.out.println("****not valid****");
ending=false;
}
}while(ending);