-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06.rb
More file actions
134 lines (112 loc) · 2.69 KB
/
Copy path06.rb
File metadata and controls
134 lines (112 loc) · 2.69 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#Printing text commands
# chap1_name = 'Chapter 1: Numbers'
# chap1_page = 'page 1'
# chap2_name = 'Chapter 2: Letters'
# chap2_page = 'page 72'
# chap3_name = 'Chapter 3: Variables'
# chap3_page = 'page 118'
# lineWidth = 42
# puts chap1_name.ljust(lineWidth/2) + chap1_page.rjust(lineWidth/2)
# puts chap2_name.ljust(lineWidth/2) + chap2_page.rjust(lineWidth/2)
# puts chap3_name.ljust(lineWidth/2) + chap3_page.rjust(lineWidth/2)
#Random numbers
#puts rand
#puts rand(5)
#puts('The weatherman said there is a '+rand(101).to_s+'% chance of rain,')
#puts('but you can never trust a weatherman.')
# srand 1
# puts(rand(100))
# puts(rand(100))
# puts(rand(100))
# puts(rand(100))
# puts(rand(100))
# puts ''
# srand 1
# puts(rand(100))
# puts(rand(100))
# puts(rand(100))
# puts(rand(100))
# puts(rand(100))
# Chapter 6 - Flow Control
# puts 1 > 2
# puts 1 < 2
# puts 5 >= 5
# puts 5 <= 4
# puts 'cat' < 'dog'
#Branching
# puts 'Hello, what\'s your name?'
# name = gets.chomp
# puts 'Hello, ' + name + '.'
# if name == 'Jon'
# puts 'What a lovely name!'
# end
# puts 'Hello, and welcome to 7th grade English.'
# puts 'My name is Mrs. Gabbard. And your name is...?'
# name = gets.chomp
# if name == name.capitalize
# puts 'Please take a seat, ' + name + '.'
# else
# puts name + '? You mean ' + name.capitalize + ', right?'
# puts 'Don\'t you even know how to spell your name??'
# reply = gets.chomp
# if reply.downcase == 'yes'
# puts 'Hmmph! Well, sit down!'
# else
# puts 'GET OUT!!'
# end
# end
# command = '' #Original
# while command != 'bye'
# puts command
# command = gets.chomp
# end
# puts 'Come again soon!'
# input = '' #Amended
# while input != 'bye'
# input = gets.chomp
# if input != 'bye'
# puts input
# end
# end
# puts 'Come again soon!'
# iAmChris = true
# iAmPurple = false
# iLikeFood = true
# iEatRocks = false
# puts (iAmChris and iLikeFood)
# puts (iLikeFood and iEatRocks)
# puts (iAmPurple and iLikeFood)
# puts (iAmPurple and iEatRocks)
# puts
# puts (iAmChris or iLikeFood)
# puts (iLikeFood or iEatRocks)
# puts (iAmPurple or iLikeFood)
# puts (iAmPurple or iEatRocks)
# puts
# puts (not iAmPurple)
# puts (not iAmChris )
# # Deaf Grandma program
# say = ''
# while say != 'BYE'
# say = gets.chomp
# while say != say.upcase
# puts 'HUH?! SPEAK UP, SONNY!'
# say = gets.chomp
# end
# year = rand(21) + 1930
# puts 'NO, NOT SINCE ' + year.to_s + '!'
# end
puts 'Input a starting year:'
start_year = gets.chomp
puts 'Input an ending year:'
end_year = gets.chomp
puts ''
while start_year.to_i <= end_year.to_i
if start_year.to_f%400 == 0
puts start_year
elsif start_year.to_f%100 == 0
elsif start_year.to_f%4 == 0
puts start_year
end
start_year = start_year.to_i + 1
end