-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
855cf13
commit 1c5290a
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env ruby | ||
|
||
people = 20 | ||
cats = 30 | ||
dogs = 15 | ||
|
||
if people < cats | ||
puts "Too many cats! The world is doomed!" | ||
end | ||
|
||
if people > cats | ||
puts "Not many cats! The world is saved!" | ||
end | ||
|
||
if people < dogs | ||
puts "The world is drooled on!" | ||
end | ||
|
||
if people > dogs | ||
puts "The world is dry!" | ||
end | ||
|
||
dogs += 5 | ||
|
||
if people >= dogs | ||
puts "People are greater than or equal to dogs." | ||
end | ||
|
||
if people <= dogs | ||
puts "People are less than or equal to dogs." | ||
end | ||
|
||
if people == dogs | ||
puts "People are dogs." | ||
end | ||
|
||
# 1. What do you think the if does to the code under it? | ||
# I think if waits to do anything with the code inside depending on the result of the if | ||
# |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env ruby | ||
|
||
people = 30 | ||
cars = 40 | ||
buses = 15 | ||
|
||
if cars > people | ||
puts "We should take the cars." | ||
elsif cars < people | ||
puts "We should not take the cars." | ||
else | ||
puts "We can't decide." | ||
end | ||
|
||
if buses > cars | ||
puts "That's too many buses." | ||
elsif buses < cars | ||
puts "Maybe we could take the buses." | ||
else | ||
puts "We still can't decide." | ||
end | ||
|
||
if people > buses | ||
puts "Alright, let's just take the buses." | ||
else | ||
puts "Fine, lets stay home then." | ||
end | ||
|
||
|
||
# Extra Credit: | ||
# 1. Try to guess what elsif and else are doing. | ||
# try the if, if that doesn't work, try the elsif, if none of those work, do the else | ||
# |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# Extra Credit: | ||
# 3. Try some more complex boolean expressions like cars > people and buses < cars. Above each line write an English description of what the line does. | ||
|
||
boys = 5 | ||
girls = 5 | ||
fathers = 10 | ||
mothers = 10 | ||
|
||
if boys and girls <= fathers | ||
puts "Boys and girls is <= fathers" | ||
end | ||
|
||
if boys and girls < fathers and mothers | ||
puts "Boys and girls is less than fathers and mothers" | ||
end | ||
|
||
if not (boys > fathers) and not (girls > mothers) | ||
puts "Scouts!" | ||
else | ||
puts "No scouts!" | ||
end | ||
|
||
if boys and girls and fathers and mothers < 50 | ||
puts "Everyone is less than 50" | ||
else | ||
puts "Everyone is more than 50" | ||
end | ||
|
||
if boys == girls and fathers == mothers | ||
puts "Boys == Girls and Fathers == Mothers" | ||
else | ||
puts "It don't all equal" | ||
end | ||
|
||
|