My assignment is to create an application that allows the user to type an item's price into a single textbox, add the price to the previously entered prices, and display the total charge which includes a $15 shipping charge and a 3% sales tax.

Example: I type 10 in the textbox and click calculate. the subtotal (before tax and shipping) reads $10. Next, I type 20 in the textbox and click calculate. The subtotal should now read $30.

I have everything working fine except adding the different prices. I cannot figure out how to retain the value of the subtotal and add it to the next value entered.

Recommended Answers

All 2 Replies

Really? Store the current total as a variable. Add the value of the textbox to it and then output the new total to the textbox. If you're having trouble keeping the current total persisting (you don't mention if this is a webpage or not) use session state or a hidden variable as part of the page.

You shouldn't even need a variable.
Add textbox value to subtotal value and you're done.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.