First let's check what we're given and what we can assume.
Since the boxes contain a quantity of pens, these quantities must be whole numbers (integers).
Assume that pens of the same colour, apart from yellow, are placed in a separate box so there are 7 boxes in all, 3 of which contain yellow pens.
Assume that the mean and medium are the mean and medium of the numbers of pens in the boxes. Let a, b and c be the numbers of pens in each yellow pen box, then:
(12+14+15+24+a+b+c)/7=16, so (65+a+b+c)=112, a+b+c=47. The mean of the boxes containing yellow pens is 47/3=15⅔. Note that the mean quantity of yellow pens is invariable not matter how many there are in each box.
Since there are 7 boxes of pens, the central number of the ordered set of numbers is 15, the median, which corresponds to the the number of green pens. We need to find out where a, b and c fit into the ordered set. Since 15 is the median, there are 3 numbers less than or equal to 15 and 3 greater than or equal to 15. Let a≤15, then b,c≥15. We can lay out the 9 ordered set possibilities:
(1.0) a, 12, 14, 15, b, c, 24; (1.1) a, 12, 14, 15, b, 24, c; (1.2) a, 12, 14, 15, 24, b, c;
(2.0) 12, a, 14, 15, b, c, 24; (2.1) 12, a, 14, 15, b, 24, c; (2.2) 12, a, 14, 15, 24, b, c;
(3.0) 12, 14, a, 15, b, c, 24; (3.1) 12, 14, a, 15, b, 24, c; (3.2) 12, 14, a, 15, 24, b, c.
We can eliminate those arrangements where a+b+c>47. For example, in 1.2 a≤12, b,c≥24. So minimum a=1 and minimum b/c=24, a+b+c=1+24+24=49, and 49>47. The strikethrough shows elimination. We can also eliminate 2.2 and 3.2. There may be other examples (not shown).
(1.0.1) a≤12, 15≤b,c≤24. There are a number of different possibilities: a=8, b=15, c=24; a=7, b=16, c=24; a=6, b=17, c=24; ...; a=1, b=22, c=24; a=9, b=15, c=23; a=8, b=16, c=23; etc.
We've already found many datasets that would fit the criteria based on the initial assumptions, which may or not be valid assumptions, but nevertheless are not ruled out by the conditions set in the question.
Here is one solution in which 15 is the median for all box numbers and also the median of the three yellow boxes: a=9, b=15, c=23, with dataset:
9 yellow, 12 black, 14 red, 15 green, 15 yellow, 23 yellow, 24 blue. Mean=16, median=15.
Because there are so many possibilities perhaps the question needs to be revised in some way to produce a unique solution?