/ruby_practice

Week 2 Exercises @ Makers Academy

Primary LanguageRuby

#Introduction to Ruby

##Makers Academy Week 2 Exercises

#####Ruby 1 and Ruby 2 Exercises from Makers Academy hackpad to learn the very basics of Ruby programming language.

###Tasks

#####Ruby 3

  • Take the method provide_mortgage?() from the "Boolean logic" section and decide if it would return true or false for these inputs without running the code:

     salary 30,000, deposit 50,000, property_value 200,000
     salary 30,000, deposit 50,000, property_value 300,000
     salary 50,000, deposit 40,000, property_value 200,000
     salary 80,000, deposit 100,000, property_value 500,000
     salary 35,000, deposit 60,000, property_value 300,000
     salary 25,000, deposit 30,000, property_value 150,000
    
  • Then run the code with these inputs and see if you're right or wrong.

  • Extend the provide_mortage?() method to require 5% deposit if the value of the property is less than 650,000 and 20% if it's 650,000 or more.

  • Extend the provide_mortgage?() method to waive the limit on the loan amount if the deposit is 75% or more.

  • Extend the method to accept another argument, a boolean value indicating if the borrower is currently bankrupt. Modify the method to never provide a mortgage to a bankrupt person.

#####Ruby 4

  • Write a Ruby program that creates a file called 'hello_from_ruby.txt'
  • Make your program ask for input and store that input for later use.
  • If the user types 'save', make your program save the input into the file.
  • If the user types 'read', show the content of the file.
  • If the user types 'introspect' make the program print itself to the screen.

###Other details

These tasks were set by Evgeny Shadchnev