Learn to Program
Chapter 5
Mixing It Up
Baby name choices
I'm going to ask for two girl names and then spit them out in a sentence.
#Baby Names
puts 'If you were to have a baby girl, what would you name her?'
gname1 = gets.chomp
puts 'What is your second choice?'
gname2 = gets.chomp
puts 'So if you had a girl, you would name her '
+ gname1 + ' or ' + gname2 + '? Those are nice names.'
Result:
Favorite Number
Ask the user for a favorite number; subtract 1 from the number. Suggest that the new number is better then their favorite number because it is smaller and more compact.
#Favorite number
puts 'What is your favorite number?'
favNumber = gets.chomp
puts favNumber + ' is a good number. But ...'
puts 'I think that ' + (favNumber.to_i - 1).to_s + ' is even better.'
puts 'Don\'t you want a better, more compact favorite number?'
Result: