wes d2a2ba9e15 first commit | 4 лет назад | |
---|---|---|
.. | ||
README.md | 4 лет назад | |
code.cpp | 4 лет назад | |
code.javascript | 4 лет назад | |
unitTest.cpp | 4 лет назад | |
unitTest.javascript | 4 лет назад |
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.