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
puts "Hi! Say something to Grandma below." | |
text = nil | |
while true | |
text = gets.chomp | |
if text == "BYE" | |
puts "Grandma didn\'t hear you. Say \"BYE\" again." | |
elsif text == text.upcase |
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
puts "What is your first name?" | |
first=gets.chomp | |
puts "What is your middle name?" | |
middle=gets.chomp | |
puts "What is your last name?" | |
last=gets.chomp | |
puts "Hello " + first + " " + middle + " " + last + ". You have an INCREDIBLE name!" |
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
puts "What is your most favoritest number in the world?" | |
fav_number = gets.chomp | |
puts "Your favorite number is " + fav_number + "? Really?" | |
new_fav = fav_number.to_i + 1 | |
puts "I think " + new_fav.to_s + " is a much better number." |
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
puts "What is your first name?" | |
first=gets.chomp | |
puts "What is your middle name?" | |
middle=gets.chomp | |
puts "What is your last name?" | |
last=gets.chomp | |
puts "Hello " + first + " " + middle + " " + last + "." | |
name_length = first.length + middle.length + last.length | |
puts "You have " + name_length.to_s + " letters in your name." |
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
puts "This is your boss. What did you want to meet about?" | |
response = gets.chomp | |
puts "WHADDAYA MEAN \"" + response.upcase + "\"" + "?!? YOU\'RE FIRED!!" |
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
line_width = 50 | |
puts "Table of Contents".center(line_width) | |
puts nil | |
puts "Chapter 1: Getting Started".ljust(line_width/2) + "page 1 ".rjust(line_width/2) | |
puts "Chapter 2: Numbers".ljust(line_width/2) + "page 9 ".rjust(line_width/2) | |
puts "Chapter 3: Letters".ljust(line_width/2) + "page 13".rjust(line_width/2) |
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
beer = 99 | |
while beer != 0 | |
#to be grammatically correct, I had to add multiple conditions | |
if beer > 2 | |
beer = beer - 1 | |
puts (beer + 1).to_s + " bottles of beer on the wall, " + (beer + 1).to_s + " bottles of beer!" | |
puts "Take one down, pass it around, " + beer.to_s + " bottles of beer on the wall!" | |
puts nil |
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
puts "What year would you like to start with?" | |
year1=gets.chomp | |
puts "And what year would you like to end with?" | |
year2=gets.chomp | |
puts nil | |
year1.to_i.step(year2.to_i,4) do |num| | |
if (num % 4 == 0 && !(num % 100 == 0 && num % 400 != 0)) |
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
puts "Enter as many words as you like." | |
puts "I\'ll sort them alphabetically for you!" | |
puts "Hit \"Enter\" on an empty line when you\'re done." | |
words = gets.chomp | |
words_array = [] | |
while words != "" | |
words_array << words.to_s.capitalize | |
words = gets.chomp |
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
line_width = 40 | |
contents = ["Table of Contents", "Chapter 1: Getting Started", "page 1 ", "Chapter 2: Numbers", "page 9 ", "Chapter 3: Letters", "page 13"] | |
puts contents[0].center(line_width) | |
puts nil | |
puts contents[1].ljust(line_width) + contents[2].rjust(line_width/3) | |
puts contents[3].ljust(line_width) + contents[4].rjust(line_width/3) | |
puts contents[5].ljust(line_width) + contents[6].rjust(line_width/3) |
OlderNewer