I don't know what language that was written in -- it looks a little like cobol, but in any event you will have to translate that into c++. Shouldn't be very difficult -- just add the code between start and stop in main() then create functions for all the others.
>> how would I go about initializing the totalCost variable and have it add up correctly for each
Declare totalCost in main() and pass it to the functions.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>> I haven't learned any specific languages yet
Then I'm confused about what it is that you wanted? And why post it in the C++ board if you aren't trying to learn c++ yet?
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
The array being filled with the order could simply contain the item numbers being ordered, one element per ordered item. Example, if the array contained 1,1,2,1,3,3, then 3 dogs, 1 fry, and 2 lemonades were ordered. Then at end of order, use each element of the array as an index into a cost array, which contains 1.25, 1.00, .75.
Or set up the array to be the number of items, each item being an element of the array. IOW, array[0] is for "hot dog". Example: 3,1,2 would be the same order as above. Then to total, multiply each array value with the cost array from above.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944