Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- First Ruby program.
- puts will give new line while print do not. No parentheses or semicolons needed!
- =end
- print "What's your first name? " #include a space at the end
- first_name = gets.chomp # gets means to get input from user, When getting input, Ruby automatically adds a blank line (or newline) after each bit of input; so chomp removes that extra line.
- first_name.capitalize! # use this method and include ! symbol to modify value contained within the variable without the need to reassign variable or assign to another variable
- print "What's your last name? "
- last_name = gets.chomp
- last_name.capitalize!
- print "What city are you from? "
- city = gets.chomp
- city.capitalize!
- print "What state or province are you from? "
- state = gets.chomp
- state.upcase! # same way as above methods, in upcase or downcase
- puts "Your name is #{first_name} #{last_name} and you're from #{city}, #{state}!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement