Place these files in a lab2 folder. Before leaving lab, zip up this folder, and hand it in.
Type each of the following expressions into irb. What value do each of the following Ruby expressions evaluate to? Is that value an integer or a floating point?
Write your answers in the file answers.txt. (Review Unit 2A lecture slides if necessary.)
In sphere_vol.rb, define a Ruby function sphere_vol(r) that calculates and returns the volume of a sphere with a radius r. This can be calculated using the formula:
\[ V = \frac{4}{3}\pi r^3\]Place in answers.txt a copy of irb lines in which you call sphere_vol(r) to compute the volume of sphere with a radius of 7 and irb shows you the result.
Pick a mathematical formula that is used in your major. In a file called my_func.rb, create Ruby function that calculates some value using that formula.
At the beginning of your my_func.rb include a comment (one or more lines of English text that start with "#" and are ignored by irb) that describes what the fomula the function computes and what units the parameters and results are in.