Last active
December 21, 2015 18:39
-
-
Save jendiamond/6348385 to your computer and use it in GitHub Desktop.
Exercise 4 - Learn Ruby the Hard Way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# defining the variable cars with the integer 100 | |
cars = 100 | |
# defining the variable space_in_car with the floating point 4.0 | |
space_in_car = 4.0 | |
# defining the variable drivers with the integer 30 | |
drivers = 30 | |
# defining the variable passengers with the integer 90 | |
passengers = 90 | |
# defining the variable passengers with the integer 90 | |
cars_not_driven = cars - drivers | |
# defining the variable cars_driven with the output of the variable drivers | |
cars_driven = drivers | |
# defining the variable carpool_capacity with the equation cars_driven multiplied by space_in_car | |
carpool_capacity = cars_driven * space_in_car | |
# defining the variable average_passengers with the equation passengers divided by cars driven | |
average_passengers_per_car = passengers / cars_driven | |
# uses the method puts to print and return to the next line; | |
# the string including the variable cars. | |
puts "There are #{cars} cars available." | |
# uses the method puts to print and return to the next line; | |
# the string including the variable drivers. | |
puts "There are only #{drivers} drivers available." | |
# uses the method puts to print and return to the next line; | |
# the string including the variable cars_not_driven. | |
puts "There will be #{cars_not_driven} empty cars today." | |
# uses the method puts to print and return to the next line; | |
# the string including the variable car# uses the method puts to print | |
# and return to the next line the string including the variable carpool_capacity. | |
puts "We can transport #{carpool_capacity} people today." | |
# uses the method puts to print and return to the next line; | |
# the string including the variable passengers. | |
puts "We have #{passengers} passengers to carpool today." | |
# uses the method puts to print and return to the next line; | |
# the string including the variable average_passengers_per_car. | |
puts "We need to put about #{average_passengers_per_car} in each car." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment