ARRAYLIST TROUBLES! with Shopping class Java Programming?

shopping cart systems
smartblonde5436 asked:


These are the errors I am getting:
Shopping.java:37: cannot find symbol
symbol : method add(Item)
location: class java.util.ArrayListjava.lang.String
cart.add(item);
^
Shopping.java:47: cannot find symbol
symbol : method cart(int)
location: class Shopping
System.out.println(cart(i).getName);
^
Shopping.java:48: cannot find symbol
symbol : method cart(int)
location: class Shopping
totalPrice += (cart(i).getPrice)*(cart(i).getQuantity);
^
Shopping.java:48: illegal start of type
totalPrice += (cart(i).getPrice)*(cart(i).getQuantity);
^
Shopping.java:48: cannot find symbol
symbol : method cart(int)
location: class Shopping
totalPrice += (cart(i).getPrice)*(cart(i).getQuantity);
^
Shopping.java:48: illegal start of type
totalPrice += (cart(i).getPrice)*(cart(i).getQuantity);
^
6 errors

HERE IS THE PROGRAM: (not including the Item Class)
/***************************************************
Shopping.java

Uses the Item class to create items and add them to a shopping
cart stored in an ArrayList.
***************************************************/

import java.util.ArrayList;
import cs1.Keyboard;

public class Shopping{
public static void main(String[] args){

ArrayListString cart = new ArrayListString();

Item item;
String itemName;
double itemPrice;
int quantity;
double totalPrice;

String keepShopping = y;

while(keepShopping.equals(y)){

System.out.print(Enter the name of the item: );
itemName = Keyboard.readString();

System.out.print(Enter the unit price: );
itemPrice = Keyboard.readDouble();

System.out.print(Enter the quantity: );
quantity = Keyboard.readInt();

//create a new item and add it to the cart
item = new Item(itemName, itemPrice, quantity);
cart.add(item);

System.out.println(Continue shopping (y/n)?);
keepShopping = Keyboard.readString();
}

//print the contents of the cart object using println

for(int i=0; i cart.size(); i++){
cart.get(i);
System.out.println(cart(i).getName);
totalPrice += (cart(i).getPrice)*(cart(i).getQuantity);
}
System.out.println(Your total cost so far: $ + totalPrice);

}
}

THANK YOU THANK YOU THANK YOU!!!! i know this is pretty easy coding but I just cannot do it and im not totally sure what i am doing and i **** this AP computer programming class !!! ahhh.
Sorry the tabbing is messed up that happened when I copied it!

Content supplied by Yahoo Answers

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Webnews
  • MisterWong
  • Y!GG

Category: Programming Design | Tags: , One comment »

One Response to “ARRAYLIST TROUBLES! with Shopping class Java Programming?”

  1. Ms

    if you want any help for arrays u can visit


Leave a Reply

You must be logged in to post a comment.