Let the marks obtained by P in mathematics and science be x and (28 − x), respectively.
According to the given condition,
When x = 12,
28 − x = 28 − 12 = 16
When x = 9,
28 − x = 28 − 9 = 19
Hence, he obtained 12 marks in mathematics and 16 marks in science or 9 marks in mathematics and 19 marks in science.