Skip to content

Solution to family.rb exercise #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions intro/01_basics/family.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
mary = 16

# Your code goes here
age_sum = mom + dad + john + mary
result = (mom * dad) / (john - mary)

puts "Sum of ages = #{age_sum}".reverse
puts "Result = #{result}".reverse
Binary file added intro/02_control_flow/.README.md.swp
Binary file not shown.
10 changes: 10 additions & 0 deletions intro/02_control_flow/names.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,14 @@
name4 = "Melisandre"

# Your code goes here
avg_length = (name1.length + name2.length + name3.length + name4.length) / 4
print "What is your name?"
my_name = gets.chomp


if avg_length >= my_name.length
print "#{my_name} is shorter than average"
else
print "#{my_name} is shorter than average"
end