-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLesson13_StudentAccountsGenerator
More file actions
45 lines (39 loc) · 2.38 KB
/
Lesson13_StudentAccountsGenerator
File metadata and controls
45 lines (39 loc) · 2.38 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
# sorry, I copied over the wrong version of the file last time!!
puts "Hi there! Let's generate some student acconuts together. Please provide me with five student names, and I will generate account details for each individual. Sound good?"
student_data = [] # blank array
studentfullnamesarray = Array.new # to combine first and last names into
studentfirstnamesarray = Array.new # gives us a blank array to later input first student names into
studentlastnamesarray = Array.new # same for their last names
studentidsarray = Array.new # likewise for student IDS
studentemailsarray = Array.new # and emails
student_data = [] # blank array - will fill with hashes later
# GATHERING STUDENT NAMES
# made a student hash to write over as needed
student_hash = { name: "Usagi Tsukino", id_no: "111111", email: "tsukino111@adadevelopersacademy.org" }
5.times do
puts "Please enter your student's first name and hit enter." # instructions for user
firstnameinput = gets.chomp.upcase # asks the user, converts uppercase
puts "Please enter your student's last name and hit enter."
lastnameinput = gets.chomp.upcase
idsinput = (prng = Random.new) # we're gunna generate numbers to be values for idsinput variable
idsgen = "#{prng.rand(111111..999999)}" # create a rando no
student_hash[:name] = ("#{firstnameinput}" + " " + "#{lastnameinput}") # puts our input into our hash
1.times do
idsinput = (prng = Random.new) # we're gunna generate numbers to be values for idsinput variable
idsgen = "#{prng.rand(111111..999999)}" # create a rando no
x=0 # start our variable at 0 outside of our loop
1.times do # start our loop
student_hash[:email] = (("#{firstnameinput}" + " " + "#{lastnameinput}") + "#{(idsgen.slice(3..5))}" + "@adadevelopersacademy.org")
# for the variable grab the first letter of the first name, full last name, and last 3 of student id and put these together. then push this into the string we created for emails.
student_hash[:id_no] = idsgen # store it in our hash
x+=1 # modify x for our loop
end
student_data.push("#{student_hash}") # put it into our array
end
end
puts "Thank you!"
# printing names and id numbers
puts "Student Accounts Generated"
# now we make a list of what we've generated
# creating .count.times to run a list of all our accounts
puts student_data