Use Pythagoras theorem. The distance between the cars, 8km, is the hypotenuse of a right angled triangle, one leg of which is 6km and the other of which is, say, x km
If you're struggling with graphing problems, I'd highly recommend that you check out Desmos and Mathaway. All you have to do is type the equations and it graphs it for you. Here's the first question: