Two different ways you could do it is one: similar to how you are but make a variable for each possibility and then compare when would have the least left over. otherwise you could just use a loop with three if statements inside to say if left on card is greater than item 1 subtract price and and a count to one. else if left on card is greater than item 2 subtract price add one to count for item two etc.
No comments:
Post a Comment