Answer:
a) John did it.
b) Carlos did it.
Step-by-step explanation:
a) If only one of them is telling the truth, it would be either Carlos or Diana. This is because statements from both imply the other is lying. If Carlos is telling the truth, then Diana's statement is a lie and if Diana's statement is true, then Carlos is lying. Since one of Diana and Carlos is telling the truth, it follows that Alice and John are lying. Alice statement, being a lie, does not point to the criminal but rather exonerates Carlos. Because John denied doing it and it has been established he is lying, then John did it. (In fact, Diana is the one telling the truth here since Carlos' statement is false.)
b) By the same reasoning at the beginning of (a), one of either Carlos or Diana is lying and the other is telling the truth. This implies Alice and John are both telling the truth. John's statement accuses no one but only exonerates himself. Alice has mentioned Carlos as the criminal and because she's telling the truth, Carlos is did it. (In fact, Carlos is also the liar, in this case, because his statement that Diana did it is false.)