d = 30 + 2(40 – s)
The machine begins the day with $30 inside, so that’s the “30 +” part. Easy enough.
The variable s is defined as how many sodas the machine has in it, but what we really care about is how many sodas are sold. We know the machine begins the day with 40, so 40 – s should give us the number of sodas sold. (When s = 40, no sodas have been sold; when s = 35, 5 sodas have been sold…)
For each soda that’s sold, the machine should have $2 more, so that’s why “2(40 – s)” is in there.
from Tumblr https://ift.tt/2AaB16F