Let the length and width be l and w, respectively. Then, perimeter = 2(l + w) = 40, and area = lw = 96. In other words:
l + w = 20
lw = 96
From here, we could guess and check to get that the length and width are 12 and 8, but let’s do this rigorously:
By the first equation, l = 20 - w
Substituting into the second equation:
(20 - w) * w = 96
w^2 - 20w + 96 = 0
w^2 - 20w + 100 = 4
(w - 10)^2 = 4
w - 10 = 2 or -2
w = 12 or 8
The rest is trivial.