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)
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)