Here is an explanation of why you get what you do, and examples of how to
resolve it.
# user enters "josh" and presses return. The return remains in the string,
as a newline
# meaning it should end in "\n", a character which, when output, indicates
the text after it
# should be placed on the next line.
puts 'What is your name?'
name = gets
puts "I received #{name.inspect}" # will output something like 'I received
"josh\n"'
puts 'What is your city?'
city = gets
puts "I received #{city.inspect}"
puts 'What is your favorite color?'
color = gets
puts "I received #{color.inspect}"
# so we when we interpolate name, the string becomes "Your name is josh\n."
# where "josh\n" was submitted by the user
# this displays as:
# Your name is josh
# .
···
#
# notice the "\n" became a newline when displayed to the screen, so the
period after it
# was displayed on the next line
# the second issue, is that individual arguments to puts are each placed on
their own line
# so you have "Your name is josh\n." that is the first argument, so puts
places a newline
# and we move to the next line before we output "You live in Wichita\n." And
since that is
# it's own argument, another newline goes after it. And then the last
argument is output, also
# with it's own newline.
puts "Your name is #{name}.", "You live in #{city}.", "Your favorite color
is #{color}."
# thus this becomes:
# "Your name is josh\n.\nYou live in Wichita\n.\nYour favorite color is
black\n.\n"
#
# which outputs like this
# Your name is josh
# .
# You live in Wichita
# .
# Your favorite color is black
# .
#
# To resolve the issues, you must do two things:
# 1. use the String method chomp to remove any newlines
# ie: gets.chomp, see documentation and examples at
http://ruby-doc.org/core/classes/String.html#M000819
#
# 2. Either join all the strings together to avoid newlines between them, as
in
# "Your name is #{name}. You live in #{city}. Your favorite color is
#{color}."
# or use a function that doesn't place newlines after each argument such as
print:
# print "Your name is #{name}.", "You live in #{city}.", "Your favorite
color is #{color}."