Scripts and Methods Exercises
Create a new file,
methods_exercises.rb. Define the following methods in this script:Write a method
#print_thrice, that accepts a string as an argument. It shouldputsthat string 3 times.def print_thrice(string) # Your code here endWrite a method,
#print_thrice_thrice, that also accepts a string as an argument. It should callprint_thricewith that string three times (for 9 total prints).Write a method,
#add_multiply_subtract, that accepts two integers as arguments. Your method should do the following:- add the two numbers
- multiply the two numbers
- subtract the sum from the product
- puts the result
You should create 3 variables (sum, product, difference) to help keep your code neat and clean!
Test your methods by invoking them in your script and running your script from the terminal.