Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Create a module called MathHelpers with the exponent() method that takes a two numbers as
- arguments and raises the first number to the power of the second number. Create a class called
- Calculator with a method called square_root() that takes the square root of the number
- (raises it to the power of 0.5). The square_root() method should use the exponent() method.
- module MathHelpers
- def exponent(num, exponent)
- return (num ** exponent)
- end
- end
- class Calcultor
- include MathHelpers
- def square_root(num)
- return exponent(num, 0.5)
- end
- end
- numnum = Calcultor.new
- numnum.square_root(4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement