Question 243046
Fundamentally, this is a distance equation, so w start with D = RT as our basic distance equation.

Train A setup:
D = 640 - distance travelled by Train B
R = x
T = 4 hrs when it passes Train B coming from the opposite direction.

Train B setup:
D = 640 - distance travelled by Train A
R = x - 20
T = 3 hrs when it passes Train A coming from the opposite direction

(i) Speed of Train B = x - 20

(ii) Distance travelled by Train A = 4x

Since the moment they pass each other they have covered the 640 km distance.  We can take our solution farther by substituting what we know.

4x + 3(x-20) = 640
4x + 3x - 60 = 640
7x = 700
x = 100

So Train A is going 100 km/hr.

We are told Train B is going 20 km/hr slower, so it is going 80.

We can check the solution by substituting these values.  And we can calculate answers to questions that have not (yet) been asked.

Train A ran 100 km/hr for 4 hrs, so it had travelled 400 km at the moment it passed Train B.
Train B ran 80 km/hr for 3 hrs, so it travelled 240 km at the moment it passed Train A.
When they pass each other, their combined distance travelled logically has to be 640, which it is.

So, we're done.