0
/ 50
For this question you will be using FoodItem objects and one GroceryBag object.
public class FoodItem { private int price; private...
For this question you will be using FoodItem objects and one GroceryBag object.
public class FoodItem
{
private int price;
private boolean onSale;
public FoodItem(int p, boolean s)
{
this.price = p;
this.onSale = s;
}
public int getPrice()
{
return price;
}
public boolean isOnSale()
{
return onSale;
}
}
The method calculateSalePrice loops over all the food items in a GroceryBag and
calculates the sum of prices. Modify the loop so that the method calculates the
sum of prices of only the items that are on sale.
Your feedback will appear here when you check your answer.