We are asked to find the probability to find a student that has a cat when we know he/she has a dog. Then, we need to know how many students have a dog, and how many have a dog and a cat.
We already know that 12 students have a dog. However we do not know how many students have a cat and a dog.
Let's calculate that.
We know we have 30 students.
We know 6 do not have dogs nor cats.
The sum of students having dogs, the students having cats and the students having none is 37, but we know that there are only 30 students. Then, we can say that 7 students have both a dog and a cat. That is just the information we needed.
Then, we can calculate the probability that a student has a cat given that they have a dog as follows:
Let's say P is that probability: