wes d2a2ba9e15 first commit | 4 years ago | |
---|---|---|
.. | ||
README.md | 4 years ago | |
code.cpp | 4 years ago | |
code.javascript | 4 years ago | |
unitTest.cpp | 4 years ago | |
unitTest.javascript | 4 years ago |
by Helen Yu tags: math, validation, conditions
Create a function that takes in three arguments (prob, prize, pay) and returns true if prob * prize > pay; otherwise return false. To illustrate, profitableGamble(0.2, 50, 9) should yield true, since the net profit is 1 (0.2 * 50 - 9), and 1 > 0. Examples profitableGamble(0.2, 50, 9) ➞ true profitableGamble(0.9, 1, 2) ➞ false profitableGamble(0.9, 3, 2) ➞
Create a function that takes in three arguments (prob, prize, pay) and returns true
if prob * prize > pay; otherwise return false
.
To illustrate, profitableGamble(0.2, 50, 9)
should yield true
, since the net profit is 1 (0.2 * 50 - 9), and 1 > 0.
profitableGamble(0.2, 50, 9) ➞ true
profitableGamble(0.9, 1, 2) ➞ false
profitableGamble(0.9, 3, 2) ➞ true
A profitable gamble is a game that yields a positive net profit, where net profit is calculated in the following manner: net_outcome = probability_of_winning * prize - cost_of_playing.