Created
August 3, 2017 01:06
-
-
Save ceci21/08a1b987096be90e6983696b22160055 to your computer and use it in GitHub Desktop.
Using a mathematical equation, calculates a coffee shop's profit based on the price of the first cup, refill price, cost to make coffee, and number of cups you get, plus how friendly you are with the cashier. Friendliness factor can only be values between 0 and 1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function profit(firstCup, refillPrice, costToMake, numberOfCups, friendlinessFactor) { | |
return ( | |
(-friendlinessFactor + 1) * | |
(Math.pow(numberOfCups, 0) * (firstCup - costToMake) + | |
Math.pow(numberOfCups, 0) * (refillPrice * (numberOfCups - 1) - costToMake * (numberOfCups - 1))) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment