The median is the balance point of area: walk in from the left and stop the instant you have covered half the total. Quartiles and percentiles are the same move with a different fraction (0.25, 0.75, p/100).
f=x2/27 on [0,3], then 31(5−x) on [3,5]. Locate the piece first.
Area of piece 1: ∫0327x2dx=31<0.5, so the median is in piece 2.
Solve in piece 2: ∫m531(5−x)dx=0.5⇒m2−10m+22=0.
(m−5)2=3⇒m=5−3 (reject 5+3).
The lower quartile (0.25<31) sits in piece 1: t3/81=0.25⇒t≈2.73.
Answer
m=5−3≈3.27,LQ≈2.73
Pick the fraction: median 0.5, quartiles 0.25 / 0.75, percentile p/100.
Piecewise? integrate to each breakpoint to find which piece holds the cutoff.
Set the area from the low end = the fraction; solve inside that piece.
Reject any root outside the domain.
On a piecewise f, locate the piece FIRST (compare the running area with the fraction), then solve inside it — and reject the out-of-range root.
Examiner note
To show a median lies in an interval, check the running area straddles 0.5; then solve algebraically and take the in-range root. (9709/62/M/J/24 Q7)(9709/62/M/J/23 Q7)
Common mistake
On a piecewise pdf, solving in the first piece without checking the cutoff is even there; keeping the root outside the domain; and doing a “show that” on the calculator (it needs full algebra).