-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbio_program.rb
More file actions
50 lines (41 loc) · 1.37 KB
/
bio_program.rb
File metadata and controls
50 lines (41 loc) · 1.37 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
#creating a bio program that accept user input and output of paragraphs contain with user input
#name
puts "What is your name?"
name = gets.chomp
#birthday
puts "What is your birthday? mm/dd/yyyy"
birthday = gets.chomp.to_s
birth_month = birthday.slice(0, 2).to_i
birth_date = birthday.slice(3, 2).to_i
birth_year = birthday.slice(6, 4).to_i
birthday = Time.local(birth_year, birth_month, birth_date)
time = Time.now
#age
age = ((time - birthday)/60/60/24/365).to_i
#birthday left
birthday_left = 0
if time.month > birth_month
birthday_left = ((Time.local(time.year + 1, birth_month, birth_date) - time)/60/60/24).to_i
else
birthday_left = ((Time.local(time.year, birth_month, birth_date) - time)/60/60/24).to_i
end
#occupation
puts "What do you do?"
occupation = gets.chomp.downcase
#hobby
puts "What's your hobby?"
hobby = gets.chomp.downcase
#favorite color
puts "What's your favorite color?"
color = gets.chomp.downcase
#print bio
print name << " is "
#determine to put an or a
if occupation.slice(0) == "a" || occupation.slice(0) == "i" || occupation.slice(0) == "e" || occupation.slice(0) == "o" || occupation.slice(0) == "u"
print "an "
else
print "a "
end
print occupation << " who is "
print age.to_s << "years old and whoes birthday is #{birthday_left}days left. Her Hobby is " << hobby
print " and her favovite color is " << color << "."