Getting a Total

Apr 29, 2014 at 11:40pm
I've been having trouble getting all my cin amounts to add together for a total amount that I can use within a void statement.
Last edited on May 9, 2014 at 3:51am
Apr 29, 2014 at 11:50pm
just create a variable named total and when each value is inputted do: total+=whatevertheamount is
Apr 30, 2014 at 12:12am
I kept getting a weird amount that didn't match up with my math
Apr 30, 2014 at 12:28am
in main create a variable total or something like that and set it to equal GetAmountSpent(). have the getAmountSpent() function add up the totals and return that total. then in main pass total(or whatever you named the variable) as a parameter to getBudgetReport() so you can use it in the function and do whatever you want with it.
Last edited on Apr 30, 2014 at 12:28am
Apr 30, 2014 at 12:41am
Oh! Okay. I hadn't thought about that. Solved the problem right away. Thanks!
Apr 30, 2014 at 12:46am
the other way would be to use reference variables, but that's a tiny bit more complicated(not really that much).
Last edited on Apr 30, 2014 at 12:47am
Topic archived. No new replies allowed.