I am trying to construct a method that will allow me to find the total cost of a number of items in an arraylist. Currently I have an arraylist full of "items." In the item class the objects have a price and a quantity found by getQuantity and getPrice. I'm trying to find the total cost of all the items in the arraylist but keep getting 5 errors. Can anyone help thanks,
EDIT: Posted the errors
public double getTotalCost()
{
double total;
for(int i = 0; i < cart.size; i++) // size has private access in ArrayList
{
total = ((cart.get(i)).getQuantity) * ((cart.get(i)).getPrice) + total; // cannot find symbol // illegal start of type// cannot find symbol // illegal start of type
}
return total;
}
}