There are two goods in the market $X1$ and $X2$ and both of their prices are positive. If an agent's utility function is given as: Q1 = amount of X1 agent buys, Q2 = amount of X2 agent buys, $u = Q1 + |Q2-5|$ Identify the demand of this agent.
Note: agent has to spend his initial endowment.
Clearly it depend on the prices, say $P1$ and $P2$, and on the agent's endowment, say $m$.
There is no point in demanding $Q2 \gt 5$: utility would be increased reducing $Q2$ to $5$ and spending the saved amount on $X1$.
For small endowments the agent will maximise utility by spending on the good with the lower price. Indeed if $P1 \lt P2$ it will always be better to buy more of $X1$ and none of $X2$. And similarly if $P1 \gt P2$ it will be better to buy more of $X2$ and none of $X1$ until $Q2=5$. So
If $P1=P2$ then there are several solutions which are convex combinations of those bullet points.
Added much later
Rereading this in the light of Amit's perceptive comment, I should have said something like:
If $P1 \le P2$ it will always be better to buy more of $X1$ and none of $X2$, and this will also be the case with small endowments and $P1 \gt P2$: in either case you get a utility of $Q1+5$.
But for $P1 \gt P2$ and a large endowment $m$ the opposite is true and you can get a higher utility of $Q2-5$ when $m/P2 - 5 \gt m/P1 +5$, i.e. when $m \gt \frac{10\,P1\, P2}{P1-P2}$. So