Final answer:
On the way to B, it took 1 hour. On the way back from B, it took 5 hours.
Step-by-step explanation:
To determine how long it took on the way to B and on the way back from B, we can use the formula:
time = distance / speed
Let's denote the time on the way to B as t1 and the time on the way back from B as t2. We can set up the following equations:
t1 + t2 = 7 (total time)
40 / 40 = t1 (distance / speed)
40 / 30 = t2 (distance / speed)
Simplifying the equations, we get:
t1 = 1 hour
t2 = 5 hours
Therefore, it took 1 hour on the way to B and 5 hours on the way back from B.