hi
i am practicing this object oriented programming where you have to program an online shopping cart, where you have to able to add and remove item to and from your cart, to be able to checkout your items and to also end when you have already checkout . I am receiving this error and would like to know how to fix it
this error is in the if statement- if(intlist.contain (item)). the contain error is saying it cannot find symbol and the item error telling me to initialized. I have tried, the this.item but it didnt work. I have tried putting contain as a variable but it didnt work because i still was getting the error cannot find symbol
public static void main(String[]args)
{
System.out.println("Hello, Welcome to the Kaisley Grocery Store");
}
ArrayList<CartItem>shoppingCart = new ArrayList<CartItem>();
Scanner userinput = new Scanner(System.in);
//static NumberFormat fmt = new NumberFormat;
ArrayList<Integer>intList = new ArrayList<Integer>();
int userChoice =0;
int intValue=0;
int total=0;
int input = 0;
Integer item=0;
String contain;
public void start()
{
int userOption=0;
do
{
showMenu();
userOption = userinput.nextInt();
chooseOption(userOption);
}while(userOption!=6);
}
public void showMenu()
{
System.out.println("Choose the correct option");
System.out.println("1: Add an item to your cart");
System.out.println("2: Remove an item from your cart");
System.out.println("3: View an item from your cart");
System.out.println("4: End shopping and goa nd check out");
System.out.println("5: Empty your cart");
System.out.println("6: Exit program");
System.out.println("Select a menu userOption");
}
public void chooseOption(int userOption)
{
if(userOption < 1 || userOption > 6)
{
System.out.println("Enter a value between 1 and 6");
}
else
{
switch(userOption)
{
case 1:
//adding an item to the cart
System.out.println("Please enter an item");
int input = userinput.nextInt();
Integer item = new Integer(input);
break;
case 2:
//remove item from the list
if(intList.contain(item))- the error is here. both contain and item is the errors am getting. contain(cannot find symbol-error) and item - item is not initialize- error am getting
{
intList.remove(item);
System.out.println(item+" has been removed");
}
else
{
System.out.println(item +" was not found on the list");
}
break;
case 3:
// to view your item in the list
System.out.println("intList");
break;
case 4:
//end shopping and add up total in cart
int i=0;
for(i = 0; i <intList.size(); i++)
{
item = intList.get(i);
total = total + intValue;
}
}
}
}

