forked from ruaridhdunbar/start_point
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruby_functions_practice.rb
68 lines (55 loc) · 1011 Bytes
/
ruby_functions_practice.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
def add(num_1, num_2)
return num_1 + num_2
end
def subtract(num_1, num_2)
return num_1 - num_2
end
def multiply(num_1, num_2)
return num_1 * num_2
end
def divide(num_1, num_2)
return num_1 / num_2
end
def return_10()
return 10
end
def length_of_string(test_string)
return test_string.length
end
def join_string(string_1, string_2)
return string_1 + string_2
end
def add_string_as_number(string_1, string_2)
return string_1.to_i + string_2.to_i
end
def number_to_full_month_name(monthnum)
if monthnum == 1
return "January"
end
if monthnum == 3
return "March"
end
if monthnum == 9
return "September"
end
end
def number_to_short_month_name(monthnum)
if monthnum == 1
return "Jan"
end
if monthnum == 3
return "Mar"
end
if monthnum == 9
return "Sep"
end
end
def cube(num)
return num ** 3
end
def sphere_rad(rad)
return ((Math::PI * 1.33) * (rad ** 3)).round(2)
end
def f_temp(temp)
return ((temp - 32) / 1.8).round(2)
end