// *************************************************************** // Shop.java // // Uses the Item class to create items and add them to a shopping // cart stored in an ArrayList. // *************************************************************** import java.util.ArrayList; import java.io.*; public class Shop { public static void main (String[] args) throws IOException { ArrayList cart = new ArrayList(); Item item; String itemName; double itemPrice; int quantity; String keepShopping = "y"; BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); do { System.out.print ("Enter the name of the item: "); itemName = keyboard.readLine(); System.out.print ("Enter the unit price: "); itemPrice = Double.parseDouble(keyboard.readLine()); System.out.print ("Enter the quantity: "); quantity = Integer.parseInt(keyboard.readLine()); // *** create a new item and add it to the cart // *** print the contents of the cart object using println System.out.print ("Continue shopping (y/n)? "); keepShopping = keyboard.readLine(); } while (keepShopping.equals("y")); } }