|
-
Mar 16th, 2000, 09:35 AM
#1
Thread Starter
Lively Member
You are to write a program that will find all the solutions to the following problem. Farmer Joe has exactly 100 dollars to spend on livestock. He needs to buy as many animals as possible. Cows cost 6 dollars, pigs cost 3 dollars, and sheep cost 4 dollars. Output all combinations of animals that Farmer Joe can purchase with out over-spending or under-spending.
Example:
Given the numbers above there are 81 solutions possible.
First solution is: 1 sheep, 0 pigs, 16 cows
Last solution is: 25 sheep, 0 pigs, 0 cows.
To receive an A on this assignment you should allow the user to enter a price for each animal and a total amount of money that Farmer Joe has to spend.
I have no idea how to go about this, and am probably screwed. Can anyone help me on this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|