Would someone please help me understand where I've gone wrong here?


#1

Would someone please help me understand where I've gone wrong here?

print puts = 'Whats your first name?'.capitalize!
first_name='seth'.capitalize!
puts= "Your first name is #{first_name}!".capitalize!

print puts='Whats your last name?'capitalize!
last_name='coward'.capitalize!
puts="Your last name is #{last_name}!".capitalize!

print puts='What city do you live in?'.capitalize!
city='cleburne'.capitalize!
puts="You live in #{cleburne}!".capitalize!

print puts='What state do you live in? ex. TX'.capitalize!
state='TX'.upcase!
puts="You live in the state of #{state}!".upcase!

print puts = "Your name is #{first_name} #{last_name} and you're from #{city}, #{state}"


Oops, try again. Did you include a print statement for each of your four variables?
#2

It's either one or the other, print OR puts. The latter will include a line break.


#3

Review Points:
1. Do not use a single quote for the string. use double quotes
2. No need to use .capitalize for all ur questions.use it only for answers
3. Do not use puts and print in a single line. use either one.Remember "Print - just prints what ever given" and "Puts - adds an additional line"
4. The main objective of receiving the input from user is not achieved here. you need to include gets.chomp to get the real time input from user.

your program in much simplified way

print "Whats your first name?"
first_name= gets.chomp.capitalize!

print "Whats your last name?"
last_name=gets.chomp.capitalize!

print "What city do you live in?"
city= gets.chomp.capitalize!

print "What state do you live in? ex TX"
state = gets.chomp.capitalize!

puts "Your name is #{first_name} #{last_name} and you're from #{city}, #{state}!"

print "Happy Coding itsss_not_seith :-)"


#4

This will give, Tx. Use .upcase! for this value so it prints as TX.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.