To gather data involving their classmates, 50 fourth graders each filled out a personal information survey sheet. In the category of pets, 22 students had a cat, 17 students had a dog, and 9 students had both a dog and a cat. If a student is randomly selected from this class, what is the probability the student will have a dog or a cat