-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriviaProject.java
More file actions
406 lines (368 loc) · 11.2 KB
/
TriviaProject.java
File metadata and controls
406 lines (368 loc) · 11.2 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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
import java.util.Scanner;
public class TriviaProject {
private static Scanner input;
public static void main(String[] args) {
Scanner playerInput;
playerInput = new Scanner(System.in);
String playerName;
System.out.println("Welcome");
System.out.println("This is a Trivia Game. Each question you get right your score will go up.");
System.out.println("You will not be penalized for each question you get wrong.");
boolean restart = true;
while(restart == true)
{
System.out.println("TYPE IN YOUR CHARACTER NAME:");
playerName = playerInput.nextLine();
System.out.println("Now that your set up " + playerName + " lets get right into the Trivia. Press Enter to continue.");
playerInput.nextLine();
int score=0;
int trys = 3;
boolean a = true;
boolean b= true;
boolean c = true;
boolean d = true;
boolean dreamt = true;
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
System.out.println(" ");
System.out.println("The first question is...");
System.out.println("Chris Pine plays the role of which character in the 2016 sci-fi film 'Star Trek Beyond'?");
System.out.println("a. Leonard McCoy");
System.out.println("b. James T. Kirk");
System.out.println("c. Pavel Chekov");
System.out.println("d. Spock");
System.out.println("");
String answer;
input = new Scanner(System.in);
while(b==true){
answer = input.nextLine();
if(answer.equalsIgnoreCase("a")){
System.out.println("Thats incorrect!");
score +=5;
System.out.println("Your score is: " + score);
b = false;
}
else if(answer.equalsIgnoreCase("b")){
System.out.println("Thats correct!");
score +=20;
System.out.println("Your score is: " + score);
b = false;
}
else if(answer.equalsIgnoreCase("c")){
System.out.println("Thats incorrect!");
score +=10;
System.out.println("Your score is: " + score);
b = false;
}
else if(answer.equalsIgnoreCase("d")){
System.out.println("Thats incorrect!");
score +=15;
System.out.println("Your score is: " + score);
b = false;
}
else{
System.out.println("Error please choose an answer from a-d:");
}
}
System.out.println("Press Enter for next question...");
playerInput.nextLine();
b = true;
System.out.println("In what year was the Nintendo 64 officially released?");
System.out.println("a. 1988");
System.out.println("b. 1993");
System.out.println("c. 1996");
System.out.println("d. 1990");
System.out.println("");
while(c==true)
{
answer = input.nextLine();
if(answer.equalsIgnoreCase("a")){
System.out.println("Thats incorrect!");
score +=5;
System.out.println("Your score is: " + score);
c = false;
}
else if(answer.equalsIgnoreCase("b")){
System.out.println("Thats incorrect!");
score +=10;
System.out.println("Your score is: " + score);
c = false;
}
else if(answer.equalsIgnoreCase("c")){
System.out.println("Thats correct!");
score +=20;
System.out.println("Your score is: " + score);
c = false;
}
else if(answer.equalsIgnoreCase("d")){
System.out.println("Thats incorrect!");
score +=10;
System.out.println("Your score is: " + score);
c = false;
}
else{
System.out.println("Error please choose an answer from a-d:");
}
}
System.out.println("Press Enter for next question...");
input.nextLine();
c= true;
System.out.println("What type of dog is Scooby Doo from the cartoon series, 'Scooby Doo'? ");
System.out.println("a. English Mastiff");
System.out.println("b. Great Dane");
System.out.println("c. Cane Corso");
System.out.println("d. Newfoundland");
System.out.println("");
while(b==true){
answer = input.nextLine();
if(answer.equalsIgnoreCase("a")){
System.out.println("Thats incorrect!");
score +=10;
System.out.println("Your score is: " + score);
b = false;
}
else if(answer.equalsIgnoreCase("b")){
System.out.println("Thats correct!");
score +=20;
System.out.println("Your score is: " + score);
b = false;
}
else if(answer.equalsIgnoreCase("c")){
System.out.println("Thats incorrect!");
score +=10;
System.out.println("Your score is: " + score);
b = false;
}
else if(answer.equalsIgnoreCase("d")){
System.out.println("Thats incorrect!");
score +=15;
System.out.println("Your score is: " + score);
b = false;
}
else{
System.out.println("Error please choose an answer from a-d:");
}
}
System.out.println("Press Enter for next question...");
input.nextLine();
b=true;
System.out.println("Which Planet is the largest planet in the solar system?");
System.out.println("a. Mars");
System.out.println("b. The Sun");
System.out.println("c. Uranus");
System.out.println("d. Jupiter");
System.out.println("");
while(d==true){
answer = input.nextLine();
if(answer.equalsIgnoreCase("a")){
System.out.println("Thats incorrect!");
score +=10;
System.out.println("Your score is: " + score);
d = false;
}
else if(answer.equalsIgnoreCase("b")){
System.out.println("Thats incorrect! Did you really just answer 'the Sun'.");
score -=10;
System.out.println("Your score is: " + score + " You lost 10 points for that answer.");
d = false;
}
else if(answer.equalsIgnoreCase("c")){
System.out.println("Thats incorrect!");
score +=10;
System.out.println("Your score is: " + score);
d = false;
}
else if(answer.equalsIgnoreCase("d")){
System.out.println("Thats correct!");
score +=20;
System.out.println("Your score is: " + score);
d = false;
}
else{
System.out.println("Error please choose an answer from a-d:");
}
}
System.out.println("Press Enter for next question...");
input.nextLine();
d=true;
System.out.println("In the board game Monopoly, if you pay to get out of jail, how much does it cost?");
System.out.println("a. 50$");
System.out.println("b. 100$");
System.out.println("c. 150$");
System.out.println("d. 200$");
System.out.println("");
while(a==true){
answer = input.nextLine();
if(answer.equalsIgnoreCase("a")){
score +=5;
System.out.println("Your score is: " + score);
System.out.println("Thats correct!");
a = false;
}
else if(answer.equalsIgnoreCase("b")){
System.out.println("Thats incorrect!");
a = false;
}
else if(answer.equalsIgnoreCase("c")){
System.out.println("Thats incorrect!");
a = false;
}
else if(answer.equalsIgnoreCase("d")){
System.out.println("Thats incorrect!");
a = false;
}
else{
System.out.println("Error please choose an answer from a-d:");
}
}
System.out.println("Press Enter for next question...");
input.nextLine();
a=true;
System.out.println("What is the most popular drink in the world that does not contain alcohol?");
System.out.println("a. Water duh");
System.out.println("b. Soda");
System.out.println("c. Coffee");
System.out.println("");
while(c==true){
answer = input.nextLine();
if(answer.equalsIgnoreCase("a")){
System.out.println("Thats incorrect!");
c = false;
}
else if(answer.equalsIgnoreCase("b")){
System.out.println("Thats incorrect!");
c = false;
}
else if(answer.equalsIgnoreCase("c")){
System.out.println("Thats correct!");
score +=30;
System.out.println("Your score is: " + score);
c = false;
}
else{
System.out.println("Error please choose an answer from a-c:");
}
}
System.out.println("Press Enter for next question...");
input.nextLine();
c=true;
System.out.println("Sound travels faster through water or steel?");
System.out.println("a. Water");
System.out.println("b. Steel");
System.out.println("");
while(b==true){
answer = input.nextLine();
if(answer.equalsIgnoreCase("a")){
System.out.println("Thats incorrect!");
b = false;
}
else if(answer.equalsIgnoreCase("b")){
score +=50;
System.out.println("Your score is: " + score);
System.out.println("Thats correct!");
b = false;
}
else{
System.out.println("Error please choose an answer from a or b:");
}
}
System.out.println("Press Enter for next question...");
input.nextLine();
b=true;
System.out.println("What is the only word in English ending in the letters 'mt'.");
System.out.println("You have 4 trys.");
System.out.println("Type the word below:");
System.out.println("");
while(dreamt==true && trys>0){
answer = input.nextLine();
if(answer.equalsIgnoreCase("dreamt")){
System.out.println("Thats correct!");
score +=200;
System.out.println("Your score is: " + score);
dreamt = false;
}
else{
System.out.println("Thats incorrect! you have " + trys + " " + "left.");
trys--;
}
}
System.out.println("Press Enter for next question...");
input.nextLine();
dreamt=true;
System.out.println("Which is the only vowel on a standard keyboard that is not on the top line of letters?");
System.out.println("You have 1 try.");
System.out.println("Type the letter below:");
System.out.println("");
while(a==true){
answer = input.nextLine();
if(answer.equalsIgnoreCase("a")){
System.out.println("Thats correct!");
score+=5;
System.out.println("Your score is Currently: " + score);
a = false;
}
else{
System.out.println("Thats incorrect!");
}
}
System.out.println("Press Enter for next question...");
input.nextLine();
a=true;
System.out.println("Do you know which child star Mila Kunis dated for eight years?");
System.out.println("a. Jonathan Lipnicki");
System.out.println("b. Haley Joel Osment");
System.out.println("c. Macaulay Culkin");
System.out.println("d. Ben Savage");
System.out.println("");
while(c==true)
{
answer = input.nextLine();
if(answer.equalsIgnoreCase("a")){
System.out.println("Thats incorrect!");
score +=5;
System.out.println("Your score is: " + score);
c = false;
}
else if(answer.equalsIgnoreCase("b")){
System.out.println("Thats incorrect!");
score +=10;
System.out.println("Your score is: " + score);
c = false;
}
else if(answer.equalsIgnoreCase("c")){
System.out.println("Thats correct!");
score +=20;
System.out.println("Your score is: " + score);
c = false;
}
else if(answer.equalsIgnoreCase("d")){
System.out.println("Thats incorrect!");
score +=10;
System.out.println();
c = false;
}
else{
System.out.println("Error please choose an answer from a-d:");
}
}
System.out.println("Press Enter to display your score...");
System.out.println(playerName + " You have scored " + score + " points.");
input.nextLine();
c= true;
String res;
System.out.println("Enter 1 to try again and 2 to quit");
res = input.nextLine();
if(res.equals("1"))
{
restart = true;
}
else
{
restart = false;
System.exit(0);
}
}
}
}