Advertisement
repente

Untitled

Oct 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. /**
  2. * Exercise 1.8 (1 points)
  3. *
  4. * Create a function called `calculateArea()` that takes one argument, the
  5. * diameter of a circle. The function should return the area of the circle,
  6. * with 4 decimals.
  7. *
  8. * Answer with the result if the diameter is 17. ( hint: `pi()` )
  9. *
  10. * Write your code below and put the answer into the variable ANSWER.
  11. */
  12.  
  13. function calculateArea($arg1) {
  14. $c = pi() * pow(($arg1/2), 2);
  15. $with_4_decimals = round($c, 4);
  16. return 'hint: ' . $with_4_decimals;
  17. }
  18.  
  19.  
  20.  
  21.  
  22.  
  23. $ANSWER = calculateArea(17);
  24.  
  25. // I will now test your answer - change false to true to get a hint.
  26. echo $dbwebb->assertEqual("1.8", $ANSWER, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement