Answer:
Let the speed of train B be x mph. Then, the speed of train A is (x+30) mph, since it is traveling 30 mph faster.
We can use the formula:
time = distance / speed
to set up two equations, one for each train:
time taken by train A = 240 / (x+30)
time taken by train B = 150 / x
Since the two trains take the same amount of time to travel their respective distances, we can set these two equations equal to each other:
240 / (x+30) = 150 / x
Cross-multiplying, we get:
240x = 150(x+30)
240x = 150x + 4500
90x = 4500
x = 50
So, the speed of train B is 50 mph, and the speed of train A is 50+30 = 80 mph.
Therefore, train A was traveling at 80 miles per hour and train B was traveling at 50 miles per hour.