Problem #2.21

library(openintro)
## Please visit openintro.org for free statistics materials
## 
## Attaching package: 'openintro'
## The following objects are masked from 'package:datasets':
## 
##     cars, trees
#2,21 Drawing box plots. After an introductory statistics course, 80% of students can successfully construct box plots. Of those who can construct box plots, 86% passed, while only 65% of those students who could not construct box plots passed.

#a) Construct a tree diagram of this scenario.
treeDiag(c('',''),c(.8,.2),list(c(.86,.14),c(.65,.35)),c('Could Construct', 'Could Not'),c('Pass','Fail'))

#b) Calculate the probability that a student is able to construct a box plot if it is known that the he passed.

pp <- .688 + .13 #adding total probability to pass
pcnp <- .688
pcgp <- pcnp/pp
pcgp
## [1] 0.8410758