After creating the loop to check that the phone number is 10 characters I beleive the phone issue is now resolved. Now I'm working with checking the email address, making sure it outputs correctly, and making sure 2 names are entered by the user. Having issues getting the email address to validate and output.
def fullname
"#{first_name} #{last_name}"
end
puts "Enter your first and last name (John Doe): "
name=gets.to_s
names=name.split(" ", 2)
puts "Enter your email address (joe@info.com): "
email=gets
puts "Enter your phone number including area code (numbers only): "
number=gets.to_i
def valid_email(email)
email=email.to_s
email="user@company_name.com"
loop do
if (email=/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i)
break
else
puts "Invalid email address entered. Please try again. "
end
end
end
def phone_number(number)
number = number.to_s
area_code = number.length == 10 ? "(#{number[0..2]}) " : ''
office_code = number[-7..-5]
specific_line = number[-4..-1]
loop do
if number =10
break
else
puts "Invalid phone number entered. Please try again."
end
end
"#{area_code}#{office_code}-#{specific_line}"
end
puts names
puts valid_email(email)
puts phone_number(number)