We need to make use of the formula:
distance = rate x time
In traffic, let's call Sally's rate x, and we know she traveled a distance of 18 mi.
Once traffic cleared, her rate is (x + 40), and we know that Sally traveled 116 mi.
If she traveled a total of 3 hours, then the time she traveled in traffic can be y, and her time once traffic cleared can be 3 - y.
We now have two equations using the formula for distance traveled:
18 = x * y = xy
116 = (x + 40)(3 - y)
We can solve the first equation for y
y = 18/x
Plug this into the second equation
116 = (x + 40) (3 - 18/x)
116 = 3x - 18 + 120 - 720/x
116 = 3x - 720/x + 102
14 = 3x - 720/x
Multiply both sides by x to clear the fraction
14x = 3x² - 720
3x² - 14x - 720 = (3x + 40)(x - 18) = 0
We can eliminate the first factor of (3x + 40) because time cannot be negative
We now have x - 18 = 0 , or x = 18
Sally's average speed in traffic is 18 mi/hr