y = mx + b
y is the total cost
The slope m is the rate: that's $8 per hour
x is the number of hours
b is the initial value: that's $16
y = 8x + 16
The problem states that the cost was $48.
Substitute that for y and solve for x.
48 = 8x + 16
32 = 8x
x = 4 hours