Created
April 12, 2016 03:20
-
-
Save LisaBee224/ea08568c1b11c6e74c00120476604743 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 convert_to_roman() | |
options = {} | |
puts "Enter a number" | |
num = gets.chomp.to_i | |
puts "Modern numerals? (Y/N)" | |
result = gets.chomp | |
if | |
result == "Y" | |
options[:modern] = true | |
elsif | |
result == "N" | |
options[:modern] = false | |
else | |
puts "sorry, not a valid value" | |
exit | |
end | |
numeral = "" | |
$letters.each do |key,value| | |
numeral += value * (num/key) | |
num -= key * (num/key) | |
end | |
if options.has_key?(:modern) && options[:modern] == true | |
$modern_letters.each do |old_nums, new_nums| | |
numeral.sub!(old_nums, new_nums) | |
end | |
end | |
p numeral | |
end | |
convert_to_roman() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment