Skip to content
Browse files

adding files

  • Loading branch information...
1 parent 2a41361 commit 23658839b2820b4ba37474a82dc04f029f5dcf48 @jholton committed
Showing with 87 additions and 0 deletions.
  1. +10 −0 ex2.rb
  2. +24 −0 ex3.rb
  3. +16 −0 ex4.rb
  4. +17 −0 ex5.rb
  5. +20 −0 ex6.rb
View
10 ex2.rb
@@ -0,0 +1,10 @@
+# A comment, this is so you can read your program later.
+# Anything after the # is ignored by Ruby.
+
+puts "I could have code like this." # and the comment after is ignored
+
+# You can also use a comment to "disable" or comment out a piece of code:
+# puts "This won't run."
+
+puts "This will run."
+
View
24 ex3.rb
@@ -0,0 +1,24 @@
+puts "I will now count my chickens:"
+
+puts "Hens", 25 + 30 / 6.0
+puts "Roosters", 100 - 25 * 3.0 % 4.0
+
+puts "Now I will count the eggs:"
+
+puts 3 + 2 + 1 - 5 + 4.0 % 2 - 1 / 4 + 6
+
+puts "Is it true that 3 + 2 < 5 - 7?"
+
+puts 3 + 2 < 5 - 7
+
+puts "What is 3 + 2?", 3 + 2
+puts "What is 5 - 7?", 5 - 7
+
+puts "Oh, that's why it's false."
+
+puts "How about some more."
+
+puts "Is it greater?", 5 > - 2
+puts "Is it greater or equal?", 5 >= -2
+puts "Is it less or equal?", 5 <= -2
+
View
16 ex4.rb
@@ -0,0 +1,16 @@
+cars = 100
+space_in_a_car = 4.0
+drivers = 30
+passengers = 90
+cars_not_driven = cars - drivers
+cars_driven = drivers
+carpool_capacity = cars_driven * space_in_a_car
+average_passengers_per_car = passengers / cars_driven
+
+puts "There are #{cars} cars available."
+puts "There are only #{drivers} drivers available."
+puts "There will be #{cars_not_driven} empty cars today."
+puts "We can transport #{carpool_capacity} people today."
+puts "We have #{passengers} passengers to carpool today."
+puts "We need to put about #{average_passengers_per_car} in each car."
+
View
17 ex5.rb
@@ -0,0 +1,17 @@
+my_name = 'Zed A. Shaw'
+my_age = 35 # not a lie
+my_height = 74 # inches
+my_weight = 180 # lbs
+my_eyes = 'Blue'
+my_teeth = 'White'
+my_hair = 'Brown'
+
+puts "Let's talk about %s." % my_name
+puts "He's %d inches tall." % my_height
+puts "He's %d pounds heavy." % my_weight
+puts "Actually that's not too heavy."
+puts "He's got %s eyes and %s hair." % [my_eyes, my_hair]
+puts "His teeh are usually %s depending on the coffee." % my_teeth
+
+# this line is tricky, try to get it exactly right
+puts "If I add %d, %d, and %d I get %d." % [my_age, my_height, my_weight, my_age + my_height + my_weight]
View
20 ex6.rb
@@ -0,0 +1,20 @@
+x = "There are #{10} types of people."
+binary = "binary"
+do_not = "don't"
+y = "Those who know #{binary} and those who #{do_not}."
+
+puts x
+puts y
+
+puts "I said: #{x}."
+puts "I also said: '#{y}'."
+
+hilarious = false
+joke_evaluation = "Isn't that joke so funny?! #{hilarious}"
+
+puts joke_evaluation
+
+w = "This is the left side of..."
+e = "a string with a right side."
+
+puts w + e

0 comments on commit 2365883

Please sign in to comment.
Something went wrong with that request. Please try again.