Skip to content

Instantly share code, notes, and snippets.

@mcbouslog
mcbouslog / Screencast #7
Last active August 29, 2015 14:20
Screencast #7
Screencast #7
puts "Welcome to the Brynn Quiz! What day of the week was Brynn born?"
answer1 = gets.chomp
puts "What year was Brynn born?"
answer2 = gets.chomp
puts "What is Brynn's middle name?"
answer3 = gets.chomp
@mcbouslog
mcbouslog / Screencast #8
Created April 30, 2015 04:13
Screencast #8
Screencast #8
puts "Welcome to the Number Guessing Game!"
puts "Guess a number between 1 and 100."
the_right_answer = rand(100)
tries = 1
10.times do
guess = gets.chomp.to_i
if guess == the_right_answer
puts "You won after " + tries.to_s + " tries!"
@mcbouslog
mcbouslog / Screencast #9
Created April 30, 2015 04:16
Screencast #9
Screencast #9
puts "Welcome! Please enter four words:"
words = []
4.times do
puts "Enter word:"
words << gets.chomp
end
@mcbouslog
mcbouslog / Screencast #10
Last active August 29, 2015 14:20
Screencast #10
Screencast #10
puts "Welcome! Please enter a word to be jumbled:"
word = gets.chomp
jumble = word.split("")
puts "Here's your jumbled word:"
puts jumble.shuffle.join
@mcbouslog
mcbouslog / Chapter 2 Exercises
Created May 1, 2015 05:03
Chapter 2 Exercises
Chapter 2 Exercises
puts "Hours in a year?"
puts 24*365
puts "Minutes in decade?"
puts ((60*24)*365)*10
puts "How many seconds old am I?"
puts (((33*365)*24)*60)*60
puts "How old is the authoer?"
puts (((1160000000/60)/60)/24)/365
@mcbouslog
mcbouslog / Screencast #11
Last active August 29, 2015 14:20
Screencast #11
Screencast #11
puts "Hello, please enter six words, one at a time:"
list = []
6.times do
list << gets.chomp
end
@mcbouslog
mcbouslog / Screencast #12
Created May 2, 2015 04:41
Screencast #12
Screencast #12
Played around in irb, did a little searching on ruby-doc.org, and the only way I could figure out how to access a variable in an array that was in an array that was in an array was to .flatten the whole array, then call the variable based on index.
@mcbouslog
mcbouslog / Screencast #13
Last active August 29, 2015 14:20
Screencast #13
Screencast #13
state_capitals = {"Illinois" => "Springfield", "Hawaii" => "Honolulu", "Kansas" => "Topeka", "New York" => "Albany", "Maryland" => "Annapolis"}
puts "Greetings! Please enter one of the following states to find out what the capital of that state is: Illinois, Hawaii, Kansas, New York or Maryland."
state = gets.chomp.capitalize
puts state_capitals[state]
@mcbouslog
mcbouslog / Chapter 5 FullNameGreeting
Created May 2, 2015 05:11
Chapter 5 FullNameGreeting
Chapter 5 FullNameGreeting
puts "Hello! What's your first name?"
first_name = gets.chomp
puts "What's your middle name?"
middle_name = gets.chomp
@mcbouslog
mcbouslog / Chapter 5 BiggerBetterNumber
Created May 2, 2015 05:28
Chapter 5 BiggerBetterNumber
Chapter 5 BiggerBetterNumber
puts "Ahoy matey, what's yer favorite number?"
fav_num = gets.chomp
better_num = fav_num.to_i + 1
better_num_string = better_num.to_s
puts "That be nice, but " + better_num_string + " would suit ya better."