Originally posted by Rick Rodriguez:
Can anyone give me any "hints" or straight forward logic guidance on this progject? Incidently, since this is a homework project, hinting would be preferred.
Originally posted by JUNILU LACAR:
It's very commendable of you to say that. I'd give you an A+ for integrity.
I suspect the modulus operator (%) would play a part in the logic and a while loop as well. You have to make some assumputions too, like what the different coin denominations are. Some countries have a 20-cent coin but no 25-cent coin.
Originally posted by Bill Norton:
You only wanted hints so hear goes:
You probably need 4 nested loops, one for each coin. In the innerest(real word?) loop you would need two test conditions:
1. adding up all four loop values to see if they equal 50
2. adding up all four loop values plus mulipling by the value(.1, .5, .10., .25) to see if equals a $1.00
If they are both true, you have your answer.
Note: on the second step you would be much better off using 1,5,10,25 and seeing if it adds up 100
Also Note: If my algebra is correct, there is only one solution, if you have to use all the coins.
Sorry if this was too much or not enough.
But I hope this helps,
Originally posted by Mike Curwen:
There is a point of confusion for me:
You said "only and all 50 coins must be used." If true, this is very simple. Add all coins up in sequence received, and if they don't make 1.00, then no other combination will do that either. If they do add up, then that must mean that ... it's on the tip of my brain...
i'll make it simpler for myself. Imagine 4 coins passed in a 4-entry array. Imagine further that they are all quarters.
The combinations are:
isn't it 4 to the 4th combinations? But maybe this logic only works because my example has been reduced to a too-simple base case.
Or for the question being asked, is this actually only one combination, and 'order' is not being considered. The problem becomes much easier if that is the case. (ie: once you find a combination of coins, you don't need to list off all possible combinations of THAT combination).
"Using any number of the 50, but only from those 50..." is probably what is meant?
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Appshttps://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous