Advertisement
Guest User

Untitled

a guest
May 6th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. Create a module called MathHelpers with the exponent() method that takes a two numbers as
  2. arguments and raises the first number to the power of the second number. Create a class called
  3. Calculator with a method called square_root() that takes the square root of the number
  4. (raises it to the power of 0.5). The square_root() method should use the exponent() method.
  5.  
  6. module MathHelpers
  7. def exponent(num, exponent)
  8. return (num ** exponent)
  9. end
  10. end
  11. class Calcultor
  12. include MathHelpers
  13. def square_root(num)
  14. return exponent(num, 0.5)
  15. end
  16. end
  17. numnum = Calcultor.new
  18. numnum.square_root(4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement