Answer
$15000$ dollars was invested in dogwood trees, and $25000$ dollars was invested in red maple trees.
Work Step by Step
Let $x$ be the amount invested in dogwood trees. Then the amount invested in red maple trees is $40000-x$. Then our equation is: $0.25x+(40000-x)\cdot0.17=40000\cdot0.2\\0.25x+6800-0.17x=8000\\0.08x=1200\\x=15000.$
$15000$ dollars was invested in dogwood trees, and $25000$ dollars was invested in red maple trees.