I'm pretty sure that I'm creating the array correctly but I dont know why the items won't add to the cart. And how would I print what the contents of the array? Please help! thanks
package shopping;
// ************************************************** *************
// Shop.java
// Uses the Item class to create items and add them to a shopping
// cart stored in an ArrayList.
// ************************************************** *************
// import ArrayList here
import java.text.NumberFormat;
import java.util.Scanner;
import java.util.ArrayList;
public class Shop {
public static void main(String[] args) {
//Declare and instantiate a variable cart as an ArrayList that can hold Item objects
Object cart[] = new Object[6];
Item item;
String itemName;
double itemPrice;
int quantity;
double totalPrice;
cart.add(item);
cart.add(itemName);
cart.add(itemPrice);
cart.add(quantity);
cart.add(totalPrice);
System.out.println("Welcome to Shopper's Paradise");
System.out.println();
Scanner scan = new Scanner(System.in);
String keepShopping = "y";
do {
System.out.print("Enter the name of the item: ");
itemName = scan.nextLine();
System.out.print("Enter the unit price: ");
itemPrice = scan.nextDouble();
System.out.print("Enter the quantity: ");
quantity = scan.nextInt();
// *** create a new item and add it to the cart
Object newItem ="Hammer";
cart[6] = "Hammer";
totalPrice = 0;
System.out.println("\nCurrent Cart");
// *** print the contents of the cart object
// *** print the total price of the cart
System.out.println(totalPrice += item.getQuantity() * item.getPrice());
System.out.println();
System.out.print("Continue shopping (y/n)? ");
scan.nextLine();
keepShopping = scan.nextLine();
} while (keepShopping.equals("y"));
}//end of main method
}//end of Shop class