-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04_02.rb
More file actions
42 lines (28 loc) · 760 Bytes
/
Copy path04_02.rb
File metadata and controls
42 lines (28 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def titlecase name
name = name.gsub(/\w+/) do |word|
word.capitalize
end
name
end
puts "Hi"
puts "What's your first name?"
input = gets.chomp
firstname = titlecase input
puts "-------------------"
puts "What's your middle name?"
input = gets.chomp
middlename = titlecase input
puts "-------------------"
puts "What's your last name?"
input = gets.chomp
lastname = titlecase input
puts "-------------------"
fullname = "#{firstname} #{middlename} #{lastname}"
puts "Hi #{fullname}"
puts "-------------------"
puts "#{firstname}, What's your favourite number?"
fav_number = gets.chomp
new_fav_number = fav_number.to_i + 1
puts "-------------------"
puts "I think your new favourite number should be #{new_fav_number}"
puts "-------------------"