Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Last active September 23, 2018 13:34
Show Gist options
  • Save harrisonmalone/53ec61b9b1472d298dc4cea42b492f02 to your computer and use it in GitHub Desktop.
Save harrisonmalone/53ec61b9b1472d298dc4cea42b492f02 to your computer and use it in GitHub Desktop.
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