How Do I Solve These Two Equations With 3 Variables? So my grandpa popped this question and I've been trying to solve this ever since. Basically, a dude needs to buy a certain amount of chickens, sheep and cows. If the chickens cost 25 cents, the sheep cost 50 cents and the cows cost 5 dollars and the total number of animals must be 20 animals and also if the money he has is 20 dollars, what and how many does he buy?
Basically, the system of equations  should be:
x + y + z = 20 and
0.25x + 0.5y + 5z = 20
I tried equating the two but it didn't seem to work. I'm sorry if something in my way of questioning is wrong, it's my first time on the Math page of Stack Exchange. Thanks in advance!
 A: Hint: solving for $x,y$ in terms of $z$ gives
$$
x=-40+18z,\quad y=60-19z.
$$
Note that $x\geq 0$ so $z\geq 3$. Similarly, $y\geq 0$ so $z<4$. It must be that $z=3$ and the rest follows: $x=14$ and $y=3$.
A: So you have a system of $2$ equations in $3$ variables:


*

*$x+y+z=20$

*$0.25x+0.5y+5z=20$


Which theoretically allows you to choose the value of $1$ variable freely.
However, there is yet another restriction, of all $3$ variables being non-negative integers.
The maximum value of $z$ is obviously $20/5=4$.
This means that there are $4+1=5$ possible values of $z$ to try:

$z=0\implies$
$x+y=20\implies$
$0.5x+0.5y=10\implies$
$0.25x+0.5y\leq10\implies$
$0.25x+0.5y+5z\leq10+5\cdot0=10<20$

$z=1\implies$
$x+y=19\implies$
$0.5x+0.5y=9.5\implies$
$0.25x+0.5y\leq9.5\implies$
$0.25x+0.5y+5z\leq9.5+5\cdot1=14.5<20$

$z=2\implies$
$x+y=18\implies$
$0.5x+0.5y=9\implies$
$0.25x+0.5y\leq9\implies$
$0.25x+0.5y+5z\leq9+5\cdot2=19<20$

$z=4\implies$
$0.25x+0.5y=0\implies$
$x,y=0\implies$
$x+y+z=0+0+4<20$

So we're left with $z=3$, hence with a system of $2$ equations in $2$ variables:


*

*$x+y+3=20$

*$0.25x+0.5y+5\cdot3=20$


Which we can easily solve:


*

*$x=14$

*$y=3$


Hence the answer is:


*

*$14$ chickens

*$3$ sheep

*$3$ cows

