Hey there!
For this problem, all you need to do is some multiplication:
40 ft per car * 28 cars = 1,120 ft total
30 ft per car * 34 cars = 1,020 ft total
You can see that Train A exceeds the limit, while Train B doesn't.
Hope this helped you out! :-)