Last active
September 23, 2018 13:34
-
-
Save harrisonmalone/53ec61b9b1472d298dc4cea42b492f02 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
square = width * 2 | |
puts "what\'s the width of your square" | |
width = gets.chomp.to_i | |
square = width ** 2 | |
p square | |
puts "what\'s the length of the rectangle" | |
length = gets.chomp.to_i | |
puts "what\'s the width of the rectangle" | |
width = gets.chomp.to_i | |
rectangle = length * width | |
p rectangle | |
# using variables and outputting stuff to the screen | |
# using a backslash in a string to output an apostrophe | |
require 'colorize' | |
puts "what\'s the temperature in celsius" | |
celsius = gets.chomp.to_i | |
fahrenheit = celsius * 1.8 + 32 | |
if fahrenheit < 60 | |
fahrenheit = fahrenheit.to_s | |
puts fahrenheit.colorize(:blue) | |
elsif fahrenheit > 80 | |
fahrenheit = fahrenheit.to_s | |
puts fahrenheit.colorize(:red) | |
else | |
fahrenheit = fahrenheit.to_s | |
puts fahrenheit.colorize(:green) | |
end | |
# using gems and a simple conditional |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment