I would like find out how to get the middle and last term together

To factor 40 z^2 - 47 z + 12 set up two sets of parentheses with 40z as the first term in both cases. Each of these grouips will have a minus sign following the 40z term since the product must be positive and the the integers add up to -47. At the same
time, draw a horizontal line underneath both of these binomials and place a 40 as the denominator. Eventually we may need to factor the 40 into 2 * 20 or 4 * 10 or 5 * 8,. but we do not know in advance what it will be.

Now, we need to find two integers (both of which are negative) whose sum is -47 while their product is 40 * 12 or 480.

Since 40 + 12 makes 52, try 20 and 24 (take half of the larger and twice of the smaller to obtain a pair of integers that will certainly have the same product). Since 20 + 24 is only 44 we need integers that are further apart (but not as far apart as 40
and 12). I multiplied 20 by 3/2 and 24 by 2/3 to obtain 30 and 16 (whose sum is 46). Next, I doubled 16 and took half of 30 to get 32 and 15. I inserted the 32 into one group and 15 into the other. (It does not matter where since both groups are the same (40z
- ) and (40z - ). Finally 40z - 32 can be factored by 8 while 40z - 15 can be factored by 5. So, we now change the 40 in the denominator to 8 * 5 and simplify to (5z -4) (8z - 3).

Setting each of these binomials to zero, we obtain z = 4/5 or z = 3/8

One does not need to use the quadratic formula, but that would certainly be another method to arrive at the same result.