Have you calculated the profit itself? It is of course, 'price times quantity minus costs' (costs are fixed cost plus marginal cost times x). Since that function turns out to be a quadratic, you can find the maximum by completing the square and finding the vertex (highest point on the graph).