To solve this problem: y will represent the number of cookies, and x the number of hours.
To find the number of cookies that CJ eats per hour, we multiply 3 (since he eats 3 per hour) by x (the number of hours)
Since there we only 24 cookies left in the box, we will need to substract 3 by the number of hours that have passed, from 24 to find the number of cookies "y":

This equation represents that the number of cookies "y" is equal to the 24 cookies that where left after 5 hours, and to that we substract 3 (which is the number of cookies per hour) by total number of hours that have passed since those 5 hours (x-5) because 5 hours that have already passed we substract them from x.
We need to simplify that equation to represent in slope-intercept form:

Now we need to determine the number of hours it would take to finish the cookies. So we are looking for the value of x, that makes y=0:

solving for the number of hours x:

It would take 13 hours for CJ to eat the entire box of cookies.