Created
April 8, 2014 01:17
-
-
Save StuartGrossman/10080148 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def temp_conversion | |
puts "Please enter tempature" | |
temp = gets.chomp | |
puts "Type 1 to convert from Celsius to Fahrenheit" | |
puts "Type 2 to convert from Fahrenheit to Celsius" | |
type = gets.chomp | |
if type == 1 | |
temp = temp.to_f - 32 | |
temp = temp * 5 | |
temp = temp / 9 | |
puts "Your tempature is now #{temp} degrees fahrenheit" | |
else | |
temp = temp.to_f * 9 | |
temp = temp / 5 + 32 | |
p "Your new tempature is now #{temp} degrees celsius" | |
end | |
end | |
#p temp_conversion | |
def guess | |
puts "I have a number between 1 and 100 try and guess it!" | |
number = gets.chomp.to_f | |
comp_num = rand(100) | |
if number < comp_num | |
p "higher!" | |
else number > comp_num | |
p "lower!" | |
end | |
while number != comp_num | |
number = gets.chomp | |
number = number.to_f | |
if number < comp_num | |
p "higher!" | |
else number > comp_num | |
p "lower!" | |
end | |
end | |
return "Congratz you found the right number! it was #{comp_num}" | |
end | |
#p guess | |
def simple_ascii | |
row = gets.chomp.to_f | |
n = 1 | |
star = "*" | |
p " " * 50 + star | |
while n <= row - 1 | |
star = star + "*" + "*" | |
p space = " " * (50 - n) + star | |
n += 1 | |
end | |
end | |
#p simple_ascii | |
def reverse(string) | |
i = 0 | |
new_arr = [] | |
string = string.split("") | |
while i <= string.count - 1 | |
new_arr << string[string.count - 1 - i] | |
i += 1 | |
end | |
return new_arr | |
end | |
#p reverse("Cat") | |
def table | |
for row_num in 1..9 | |
line = "" | |
for col_num in 1..9 | |
line += "#{row_num * col_num}\t" | |
end | |
puts line | |
end | |
end | |
#p table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment