Let H be the number of extra hours you rented the bike.
The total cost of the bike rental is $24 for the ride plus $4.50 for each extra hour, so the equation is:
24 + 4.50H = 42
To solve this equation, we can subtract 24 from both sides to get:
4.50H = 42 - 24
Then we can simplify the right side to get:
4.50H = 18
Finally, we can divide both sides by 4.50 to find the number of extra hours H:
H = 18 / 4.50
H = 4
So you rented the bike for 4 extra hours.