arslan, maybe this'll help kick it off for you...

Your profit function , for any Q, is just Revenue less Cost, or

When you putRandQtogether, you'll end up with a single function / equation for profit:

Now you can see that your profit function is a quadratic, graphically represented by a downward-opening parabola (the leading term has a negative coefficient).

Maximum profit is achieved at the vertex of that parabola. You can determine that vertex using your favorite weapon of choice: Either via algebra (rearrange the equation into "vertex" form), or calculus (find the Q at which the first derivative = 0).

That'll get you running with ball, at least. Best of luck with it!