I got this project in class and it works for the most part but there is one issues I have been fiddling around with for about 3 hours now and can't quite seem to get it and I apologize for it being a bit sloppy but a few tips would be nice.
Examples
.70 Price
$1.00 Payed With
Change some reason displays
2 Dime's and no pennies even though it should be 4 pennies
a) dont use system
b) dont use usingnamespace std;
c) never use goto or this will happen: http://xkcd.com/292/
d) for the money() function i would use the modulo operator (%)
That was just parts of my many attempts to make this work and I know I just have been desperate to get it to work so I'll try those now. Thank you. Also you explain more on where to put the modulo operator.
I have tried that and it caused only a few examples to work because the other example is 12.70 for cost and $100 as payment and a penny will not show up.
You're rounding up with the setprecision(2) when you display the change to the user but that's not actually changing the value of the variable Change that's sent to the Money function.
I removed the setprecision(2) so that the change displayed the actual value of the variable. Your change running through the long list of if statements is $86.40, so that explains the missing penny. (Your text for the breakdown is off - I think you meant 1 $20 and 1 $10 instead of 2 $20.)
Item Cost:Money Given:Your change is $86.408687.
1 $50 Bill
2 $20 Bill's
1 $5 Bill
1 $1 Dollar
1 Quarter
1 Dime
1 Nickel
This doesn't use the modulus operator - but this is another way to separate out the bills for change. I just did the whole dollar bills, but coins could be done in a similar way. (77.20 is just a sample value)
I know I am having quite an issue with the penny if statement I have tried many different ways of fixing it but I will not work for both examples it will work for one but not the other and 2 $20's work fine if you do the math. I appreciate the feed back though.
I apologize about that I had a dunce moment with my math and is there any possible way I could round to fix this issue and wild blue I might try your idea most likely so thank you.