Since the rule of distance is

Where v is the speed and t is the time
Since the distance from home to the book store is equal to the distance from the book store to the home, then
Let the distance = d
Since the speed in the going way is 15 mph, then

Since the speed in the back way is 25 mph, then

Since the time of the entire trip is 4 hours, then

Substitute the values of t1 and t2

Multiply both sides by 75 (L.C.M of 15 and 25)

Divide both sides by 8

Substitute d by 37.5 in t1 to find it

It took him 2.5 hours to get to the book store