Use conditional probability:
[tex]P(A|B) = \frac{P(AB)}{P(B)}[/tex]
For part 1)
A = Has cancer
B = Test indicates cancer
We know that P(A) = 0.02 and the test has 0.99 success rate.
The test will be positive for 99% of those with cancer and 1% of those without.
P(B) = (.02)(.99) + (.98)(.01)
P(AB) is only for those who both have cancer and test positive, (.02)(.99)
[tex]P(A|B) = \frac{.02*.99}{.02*.99 + .98*.01} = 0.6689[/tex]
Part 2 is similar except B is now Test is negative.
The is true for 1% for those with cancer, 99% for those without.
P(B) = (.02)(.01)+(.98)(.99)
P(AB) is if you both have cancer and test negative, (.02)(.01)
[tex]P(A|B) = \frac{.02*.01}{.02*.01+.98*.99} = 0.0002[/tex]