forked from mikegehard/LearnRubyTheHardWay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex3.rb
41 lines (28 loc) · 1.42 KB
/
ex3.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Exercise 3 (plus extra credit items)
puts "I will now count my chickens:"
# Counts my chickens.
# Perhaps there are 2 hen houses, and I share the 30 hens in one with 5 other people
# 30 divided by six plus 25 printed to screen.
puts "Hens", 25 + 30 / 6
# Perhaps I'm rooster rich and hen poor, and have really over complicated thier allocation with my fellow chicken farmers
# 25 multiplied by 3, modulo 4, subtracted from 100 printed to screen.
puts "Roosters", 100 - 25 * 3 % 4
puts "Now I will count the eggs:"
# 1 divided by 4, subtracted from 4 modulo 2, plus 3 plus 2 plus 1 minus 5 plus 6 printed to screen.
puts 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0
# original must round up to integer... yes it does, easy fix.
puts "Is it true that 3 + 2 < 5 - 7?"
# determines if 3 plus 2 is less than five minus seven, and prints result to screen
puts 3 + 2 < 5 - 7
# adds 3 and 2 then prints results to screen.
puts "What is 3 + 2?", 3 + 2
# subtracts 5 from 7 then prints results to screen.
puts "What is 5 - 7?", 5 - 7
puts "Oh, that's why it's false."
puts "How about some more."
# Determines if 5 is greater than minus 2 then prints results to screen.
puts "Is it greater?", 5 > -2
# Determines if 5 is greater than or equal to minus 2 then prints results to screen.
puts "Is it greater or equal?", 5 >= -2
# Determines if 5 is less than or equal to minus 2 then prints results to screen.
puts "Is it less or equal?", 5 <= -2