File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Help, suggestions needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help, suggestions needed" Watch "Help, suggestions needed" New topic

Help, suggestions needed

arpit singla
Ranch Hand

Joined: Jun 18, 2001
Posts: 66
I am working on a shopping cart. I have list of books, each book has a link "Add to Cart", which adds books to a vector. When clicked on some other book it is also added to vector. I display all these books along with price and Author by enumerating through the vector.
Problem: I want to display the Grand total(price of book1 + price of book2) of books, how can i do that?
Part of code which displays elements of class shoppingcartElement is:
Enumeration en =vec.elements();
shoppingcartElement shopelement1 = (shoppingcartElement)en.nextElement();
// instance)+(newinstance);
My shoppingcartElement class:
import java.lang.*;
import java.util.*;
public class shoppingcartElement extends Object{

public String bookname;
public double price ;
public int quantity;
public int sku;
public double total;
thanks for the help in advance.
jon boydell

Joined: Jul 04, 2001
Posts: 15
how about using..
GrandTotal = 0;
loop {
GrandTotal = GrandTotal+currentItem.price
Consider Paul's rocket mass heater.
subject: Help, suggestions needed
It's not a secret anymore!