let's start by defining two variables: A and B, for trains A and B, respectively.
we can now create a system of equations:
A + B = 368 ("...weigh a total of 368 tons.")
A - B = 340 ("The difference of their weights is 340 tons.")
now, let's add up these two equations.
A + B + A - B = 368 + 340
2A = 708
A = 354
to solve for B, we just plug in our value of A into one of our initial equations.
354 + B = 368
B = 368 - 354
B = 14
hope this helped! please let me know if you have any questions :)