This is the solution to an algebra problem which I (and about 20 other people) were trying to find formulas for. We finally decided it was impossible to solve using algebra without assuming at least one constant since only two formulas are available and there are three variables. For this reason, I resorted to writing a program to figure it out. I used embedded for...next loops in a pseudo-recursive fashion similar to the change for a dollar problem which every level 1 programmer has done.
The problem goes something like this: Farmer Jones wants to purchase 100 animals and spend exactly $100. Cows cost $10.00, Pigs cost $2.00, and Chickens cost $.50. How many of each could the farmer buy?
I decided to write the program so all 5 of the above numbers could be modified (just for the fun of it I guess). Anyway, there are 2 answers to the above problem, all you have to do is click the button to see the answer, or you can play around with the numbers if you feel like it. Just be careful, if you put in dollar signs or anything other than numbers, there is no error checking in the program so the results will be unpredictable.
If your interested, here is a link to the source code for the applet. FarmerJonesApplet.java or FarmerJonesApplet.txt
Also check out one of the more useful JAVA programs I have created. Weight and balance calculators for light GA airplanes. The program is fairly simple to customize for any light plane so if you know anyone who could use the program, let me know. Steve@Danhof.net
The download thing below isn't
working at present and I don't
feel like fixing it right now.
| If you cannot view the JAVA applet to the left, you must download the JAVA 2 Runtime Environment. | ||
![]() |
||
![]() |
||
|
|
||
|
|
||
|
|