You need to build the following equation:
The total distance that needs to be traveled both ways is 120 miles. The average speed that we need to obtain is 40 miles; therefore, the car must travel for 3 hours in order to achieve that:
120 miles/40 miles per hour = 3 hours
The car has already traveled for two hours:
60 miles/30 miles per hour = 2 hours
So, on the way back it needs to travel only 1 hour. The distance is 60 miles. Hence the car needs to travel at 60 miles per hour.