I'm having trouble to code a function to keep track of a subtotal. My program is basically asking a user what are they buying, how much is it, & calculates the total. Then it asks them if they are purchasing something else. I want the total for the 2nd purchase to be added to the first one and so forth. I left the "subTotal" function empty because I tried so many things and it did not work.
You don't need a function for that, it's one line of code to add (well, it's two). Before enetring the loop declare a variable to hold the total int total = 0;. Then, after the purchase at the end of loop add this line: total += order.total;