Formatting with String Methods Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Write a small program that will read a user’s input, asking them what their first name, last name, what city their from and in which state/ province it’s in. At the end print this to the console. While also correcting his or her capitalization.

A
print “What’s your first name? ”
first_name = gets.chomp
first_name.capitalize!
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/ province are you from? ”
state = gets.chomp
state.upcase!
How well did you know this?
1
Not at all
2
3
4
5
Perfectly