Hi guys. I just need an example of a java program that accumulates total.
I'm using Jgrasp to compile the program.
If possible, please answer the question below so I can get an example on how to do a loop program that accumulates total.
Here's the problem:
Write a program that calculates the cost of buying a burger from the CIS 103 Super Burger store. The menus has four choices to choose from:
Menu Cost ($)
Combo 1 (Fries + Drink) 3.50
Combo 2 ( Cheese + Fries + Drink) 4.85
Combo 3 (Double Cheese Burger + Fries + Drink) 5.25
The program presents a menu that allows the user to choose the desired burger combo. When the user selects an item, the program displays the cost. When the user selects option 5, the program displays the accumulated total cost.
A couple of general tips, though. When dealing with money, it's generally a bad idea to use floats. use some kind of int, and use the atomic unit. When dealing with American currency, store everything as pennies, and convert when you want to display.
Also, don't write 43 lines of code at a time. Many folks here will tell you to write as little as possible (sometimes even only ONE line) and then compile/test/fix until you KNOW that works...then add some more.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors