Courses‎ > ‎Intro to CS - Half Year‎ > ‎Dyrland-Weaver‎ > ‎Work‎ > ‎

### Work 05: 9/20

posted Sep 20, 2018, 10:37 AM by JonAlf Dyrland-Weaver   [ updated Sep 20, 2018, 12:19 PM ]
 Write the following functions in racketaverage3Has 3 number parameters.Returns the average of those three numbers.examples(average3 1 2 3) ==> 2(average3 23 176 5) ==> 68 tipTakes one argument representing the cost of a meal.Returns the total amount you should pay including an 18% tipExamples(tip 100) ==> 118(tip 64) ==> 75.52gravityTakes 3 arguments representing the masses of 2 objects and the distance between them.Returns the gravitational force as calculated by Newton's formula:Force = (G * mass1 * mass2) / distance2G is a constant defined as 6.674 * 10-11 , which can be written as 6.674e-11 in racket.Examples(gravity 1 2 3) ==> 0.000000000014831(gravity 100000 20000000 6) ==> 3.707coinValueHas 4 parameters representing the number of pennies, nickels, dimes and quarters, respectively.Returns the total value, in dollars, of the coinsExamples:(coinValue 1 2 3 4) ==> 1.41(coinValue 2 2 2 2) ==> 0.82Note: you might actually get a number like 0.8200000000000001 backgetHundredsDigitTakes one argument representing an integer.Returns the hundreds digit of that number.Examples(getHundredsDigit 234) ==> 2(getHundredsDigit 76348) ==> 3Hint: you may find a function from the previous assignment helpful.Submit this as test0-review