Embarrassingly simple: getting a calculator to include decimals?
Basically, I need to add a sort of shopping-cart calculator to the site. There's a list of products, and beside each product, a "Quantity" field. The calculator knows that Product X is $2.70 and Product Y is $4, so when the user hits the 'calculate total' button, it multiplies each product's price by its quantity, adds them all up, and gives a total figure.
That's it. Simple, right?
Well, here's what I've done so far. I added comments for each section so it'd be clear what I'm trying (and failing) to do. http://pastebin.com/raw.php?i=Cd60NY8R
Now, what I've got there actually does work perfectly fine -- except that it doesn't calculate decimals, and that's a problem for me. Some of the prices need to be things like $3.70, and that calculator doesn't understand that.
My initial idea was to simply list all the prices in cents, and have the Cal function divide by 100 as its last step. But I'm not sure how to actually add that to the code -- nothing I've tried works.
Could anyone tip me off as to how I might do that? I'd be grateful.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)