Background
The question arises from the following real-life situation: I buy a newspaper at 3 dollars and sell it at 6 dollars. I know the demand for news paper is a binomial random variable with $n=12$ and $p=0.7$, I want to maximise my expected profit.
Problem
The answer is obviously 8 because it is nearest to the expected demand for newspaper. But my question is about how this can be derived more vigorously. My attempt is as follows but I am stuck at the last step:
Let $p$ be the newspaper I purchased, and X be the demand for newspaper, then the profit is a discrete random variable with the following functional forms:
$$Y= \begin{cases} 6X-3p & X<p \\ 3p & X \geq p \end{cases} $$
The answer is obtained when the expectation of Y is obtained in terms of p. Then it is a function to be maximised. But the problem now is: how can the expectation of such a random variable that depends on another random variable be obtained? I would very appreciate a proof of why a method works.