Since the trains travel toward each other, their speeds add up to close the gap between them.
Setup: Let t be the number of hours until they meet. Each train travels for the same time t, because they leave together.
Distance by train 1: 60t
Distance by train 2: 40t
When they meet, the two distances together equal the full 300 miles:
60t + 40t = 300
Solve: Combine like terms to get 100t = 300, then divide both sides by 100 to get t = 3.
So they meet 3 hours after departure.
Check: In 3 hours, the first train goes 60 × 3 = 180 miles and the second goes 40 × 3 = 120 miles. Together that is 180 + 120 = 300 miles, which matches the distance between the cities.
Shortcut: Think of the closing speed as 60 + 40 = 100 mph. Then time = distance ÷ closing speed = 300 ÷ 100 = 3 hours.
If you want to know where they meet, use either train's distance. The meeting point is 180 miles from the first train's starting city (and 120 miles from the other).