-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruby_review.rb
More file actions
62 lines (52 loc) · 1.28 KB
/
Copy pathruby_review.rb
File metadata and controls
62 lines (52 loc) · 1.28 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# puts "What are your five favorite foods?"
# fave_foods = []
# 5.times do
# food = gets.chomp
# fave_foods << food
# end
# # i = 0
# # 5.times do
# # puts "I love #{fave_foods[i]}"
# # i = i + 1
# # end
# i = 0
# 5.times do
# puts "#{i + 1}. #{fave_foods[i]}"
# i = i + 1
# end
info = []
5.times do
puts "Enter a first name, last name and email: "
people = {}
first_name = gets.chomp
last_name = gets.chomp
email = gets.chomp
if email.index("@") == nil || email.index(".com") == nil
puts "invalid email"
end
account = rand(10 ** 10)
people["first_name"] = first_name
people["last_name"] = last_name
people["email"] = email
people["account"] = account
info << people
end
i = 0
while i < info.length
puts "FIRST NAME: #{info[i]["first_name"]}"
puts "LAST NAME: #{info[i]["last_name"]}"
puts "EMAIL: #{info[i]["email"]}"
puts "ACCOUNT #: #{info[i]["account"]}"
i = i + 1
end
puts "Enter an account number:"
account_number = gets.chomp.to_i
i = 0
while i < info.length
if account_number == info[i]["account"]
puts "FIRST NAME: #{info[i]["first_name"]}"
puts "LAST NAME: #{info[i]["last_name"]}"
puts "EMAIL: #{info[i]["email"]}"
end
i = i + 1
end