This is a proportion question.
0.5:40 miles :: 5:x
Translated into division you get 0.5/40 = 5/x Cross multiply
0.5 x = 40 * 5 combine the right
0.5x = 200 divide by 0.5
0.5x/0.5 = 200/0.5 Divide
x = 400
Answer: The two cities are 400 miles apart