-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquiz_1.rb
197 lines (172 loc) · 4.33 KB
/
quiz_1.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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
question_one = {
question: "What is the capital of Canada?",
answer: "A",
answer_choices: [
"A - Ottawa",
"B - Washington, D.C.",
"C - San Francisco"
]
}
question_two = {
question: "What is the capital of Argentina?",
answer: "C",
answer_choices: [
"A - Lima",
"B - Brasilia",
"C - Buenos Aires"
]
}
question_three = {
question: "What is the capital of Poland?",
answer: "B",
answer_choices: [
"A - Rome",
"B - Warsaw",
"C - Moscow"
]
}
question_four = {
question: "What is the capital of Japan?",
answer: "C",
answer_choices: [
"A - Beijing",
"B - Melbourne",
"C - Tokyo"
]
}
question_five = {
question: "What is the capital of Australia?",
answer: "B",
answer_choices: [
"A - Sydney",
"B - Canberra",
"C - Perth"
]
}
question_six = {
question: "What is the capital of Tanzania?",
answer: "B",
answer_choices: [
"A - Dar es Salaam",
"B - Dodoma",
"C - Nairobi"
]
}
question_seven = {
question: "What is the capital of Nigeria?",
answer: "C",
answer_choices: [
"A - Lagos",
"B - Tunis",
"C - Abuja"
]
}
question_eight = {
question: "What is the capital of Germany?",
answer: "B",
answer_choices: [
"A - Munich",
"B - Berlin",
"C - Bonn"
]
}
question_nine = {
question: "What is the capital of Mexico?",
answer: "A",
answer_choices: [
"A - Mexico City",
"B - Cancun",
"C - Oaxaca"
]
}
question_ten = {
question: "What is the capital of Italy?",
answer: "C",
answer_choices: [
"A - Milan",
"B - Florence",
"C - Rome"
]
}
quiz = [question_one, question_two, question_three, question_four, question_five, question_six, question_seven, question_eight, question_nine, question_ten]
quiz_answers = []
puts "What is your name? "
user_name = gets.chomp
puts "#{user_name.capitalize}, would you like to take a quiz? Type Yes or No."
quiz_time = gets.chomp
if quiz_time == "yes" || quiz_time == "Yes"
puts quiz[0][:question]
puts quiz[0][:answer_choices]
answer_one = gets.chomp
if answer_one == "A" || answer_one == "Ottawa" || answer_one == "a" || answer_one == "ottawa"
quiz_answers.push(answer_one)
else
end
puts quiz[1][:question]
puts quiz[1][:answer_choices]
answer_two = gets.chomp
if answer_two == "C" || answer_two == "Buenos Aires" || answer_two == "c" || answer_two == "buenos aires" || answer_two == "Buenos aires"
quiz_answers.push(answer_two)
else
end
puts quiz[2][:question]
puts quiz[2][:answer_choices]
answer_three = gets.chomp
if answer_three == "B" || answer_three == "Warsaw" || answer_three == "b" || answer_three == "warsaw"
quiz_answers.push(answer_three)
else
end
puts quiz[3][:question]
puts quiz[3][:answer_choices]
answer_four = gets.chomp
if answer_four == "C" || answer_four == "Tokyo" || answer_four == "c" || answer_four == "tokyo"
quiz_answers.push(answer_four)
else
end
puts quiz[4][:question]
puts quiz[4][:answer_choices]
answer_five = gets.chomp
if answer_five == "B" || answer_five == "Canberra" || answer_five == "b" || answer_five == "canberra"
quiz_answers.push(answer_five)
else
end
puts quiz[5][:question]
puts quiz[5][:answer_choices]
answer_six = gets.chomp
if answer_six == "B" || answer_six == "Dodoma" || answer_six == "b" || answer_six == "dodoma"
quiz_answers.push(answer_six)
else
end
puts quiz[6][:question]
puts quiz[6][:answer_choices]
answer_seven = gets.chomp
if answer_seven == "C" || answer_seven == "Abuja" || answer_seven == "c" || answer_seven == "abuja"
quiz_answers.push(answer_seven)
else
end
puts quiz[7][:question]
puts quiz[7][:answer_choices]
answer_eight = gets.chomp
if answer_eight == "B" || answer_eight == "Berlin" || answer_eight == "b" || answer_eight == "berlin"
quiz_answers.push(answer_eight)
else
end
puts quiz[8][:question]
puts quiz[8][:answer_choices]
answer_nine = gets.chomp
if answer_nine == "A" || answer_nine == "Mexico City" || answer_nine == "a" || answer_nine == "mexico city" || answer_nine == "Mexico city"
quiz_answers.push(answer_nine)
else
end
puts quiz[9][:question]
puts quiz[9][:answer_choices]
answer_ten = gets.chomp
if answer_ten == "C" || answer_ten == "Rome" || answer_ten == "c" || answer_ten == "rome"
quiz_answers.push(answer_ten)
else
end
results = quiz_answers.length
puts "Thank you for taking this quiz #{user_name.capitalize}! You got #{results} out of 10 right!"
else
puts "That's OK, you don't have to take a quiz."
end