Completed exercise4.rb