Explanation:
I think there is a mistake in the problem description.
f and p are for the price of 1 yards fencing and 1 post.
and not the amounts.
because the problem description gives us the amounts already (30+8 yards fencing and 4 posts).
based on the 8 more yards of fencing for $256 we know that 1 yard of fencing costs $32.
we know from the beginning
30f + 4p = 1040
and again
8f = 256
f = $32
now using that in the first equation
30×32 + 4p = 1040
960 + 4p = 1040
4p = 80
p = $20
he bought first 30 and then additional 8 yards of fencing for $32 per yard, and 4 posts for $20 per post.
altogether he had to pay 1040+256 = $1296