-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
407 lines (313 loc) · 15.3 KB
/
Main.java
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
405
406
407
/*
Project Lead: Samuel Segovia
Authors: Samuel Segovia, Cristian Herrera,Shane Powell, Jason Yang, Logan Sanchez, Bryan Abrego, Peter Kallos,
Kevin Flores, Frances Kaufmann, Angelica Holley
Contributions: Shebly Gallegos, CIS 111 Zybooks
Project Name: STEM_Trivia
Comppletion Date: 10/09/2022
Description: This project is a trivia game featuring 10 questions with some being STEM related questions and some being of another topic.
After answering the 10 questions, the amount of answers correct is counted using the numCorrect variable, and the correct
number of correct answers will be displayed along with an end message.
***EDITORS NOTE***
- When presenting the project:
- Zoom out website to 80% to make the CODE presentable.
- Drag Console window to the side when presenting code.
- Zoom in website to 125% to make the CONSOLE presentable.
- Press "Maximize" on the top right corner of the console when running the code.
*/
import java.util.Scanner;
class Main {
public static void main(String[] args) {
// ALLOWS INPUT
Scanner scnr = new Scanner(System.in);
// VARIABLES
String answer; // Stores answer inputted by user
String continueEnter; // Leaves the question up until user presses enter
int numCorrect = 0; // Counts how many answers the user got right
/*-------------------------------------------------------------------------------------------------------------------------*/
// Title Screen
System.out.println("\n AVC STEM Club Computer Science Committee presents:");
System.out.println("\t\t _____ _________ ________ _ _ ");
System.out.println("\t\t / \\ | | / \\ / \\ ");
System.out.println("\t\t \\_____ | |_______ / \\ / \\ ");
System.out.println("\t\t \\ | | / \\/ \\");
System.out.println("\t\t \\_____/ | |_______ | | ");
System.out.println(" _________ ______ _________ _________ _ ");
System.out.println(" | | \\ | \\ / | / \\ ");
System.out.println(" | |_____/ | \\ / | /___\\ ");
System.out.println(" | | \\ | \\ / | / \\ ");
System.out.println(" | | \\ ____|____ \\/ ____|____ / \\");
System.out.println("\n\n\t\t- A Triva Game featuring STEM and non-STEM related questions ");
System.out.println("\nPress enter to start:"); // Prompts user to press enter to go to next question
continueEnter = scnr.nextLine();
// Clear screen code
System.out.print("\033[H\033[2J");
System.out.flush();
/*-------------------------------------------------------------------------------------------------------------------------*/
// Samuel's Question
// Outputs Question
System.out.println("QUESTION 1");
System.out.println("The first computer bug ever found was an actual bug,");
System.out.println("which one was it?");
// Outputs Choices
System.out.println("A. Fly ");
System.out.println("B. Bee");
System.out.println("C. Moth");
System.out.println("D. Ant");
answer = scnr.nextLine(); // Answer is the variable that recieves input value from the user
// If-Else Statement
if (answer.equalsIgnoreCase("C")) { // Asks if answer equals capital or lowercase letter
numCorrect++;
System.out.println("Correct Answer! The first bug was in fact a moth!"); // Prints out correct if above statement is
// true
} else {
System.out.println("Wrong Answer! The right answer is - wait I'm not telling."); // the else statement will be
// used when answer is wrong
}
System.out.println("Press enter to continue."); // Prompts user to press enter to go to next question
continueEnter = scnr.nextLine();
// Clear screen code
System.out.print("\033[H\033[2J");
System.out.flush();
/*-------------------------------------------------------------------------------------------------------------------------*/
// Logan's question
System.out.println("QUESTION 2");
System.out
.println("Who is your best choice as a survival partner in a zombie apocalypse?( There is a correct answer)");
System.out.println("A. Mike Tyson");
System.out.println("B. OJ Simpson");
System.out.println("C. Hannibal");
System.out.println("D. Michael Jackson");
answer = scnr.nextLine();
if (answer.equalsIgnoreCase("D")) {
numCorrect++;
System.out.println(
"Correct! While the others are good at killing or eating living people, Michael Jackson is the only one with the ability to control zombies; doing so by dancing in the street.");
} else {
System.out.println("Unfortunately, you would... die.");
}
System.out.println("Press enter to continue.");
continueEnter = scnr.nextLine();
System.out.print("\033[H\033[2J");
System.out.flush();
/*-------------------------------------------------------------------------------------------------------------------------*/
// Peter's Question
System.out.println("QUESTION 3");
System.out.println("Which holiday is Halloween most closely associated with?");
System.out.println("A. Christmas");
System.out.println("B. Easter");
System.out.println("C. Thanksgiving");
System.out.println("D. All Saints' Day");
answer = scnr.nextLine();
if (answer.equalsIgnoreCase("D")) {
numCorrect++;
System.out.println("Correct!");
} else {
System.out.println("Incorrect. It's All Saints' Day");
}
System.out.println("Press enter to continue.");
continueEnter = scnr.nextLine();
System.out.print("\033[H\033[2J");
System.out.flush();
/*-------------------------------------------------------------------------------------------------------------------------*/
// Frances' Question
System.out.println("QUESTION 4");
System.out.println("What was candy corn originally called?");
System.out.println("A. Chicken Feed");
System.out.println("B. Pumpkin corn");
System.out.println("C. Chicken wings");
System.out.println("D. Air heads");
answer = scnr.nextLine();
if (answer.equalsIgnoreCase("A")) {
numCorrect++;
System.out.println("Lucky guess");
} else {
System.out.println("Wrong! It's chicken feed");
}
System.out.println("Press enter to continue.");
continueEnter = scnr.nextLine();
System.out.print("\033[H\033[2J");
System.out.flush();
/*-------------------------------------------------------------------------------------------------------------------------*/
// Angelica's question
System.out.println("QUESTION 5");
System.out.println("What was the first computer system that used color display?");
System.out.println("A. IBM 650");
System.out.println("B. Apple 1");
System.out.println("C. Atanasoff-Berry Computer");
System.out.println("D. Hewlett-Packard");
answer = scnr.nextLine();
if (answer.equalsIgnoreCase("B")) {
numCorrect++;
System.out.println("Coooooorrect! Apple's a goat");
} else {
System.out.println("wrong!! you're so dumb lol. It's obvi the Apple 1");
}
System.out.println("Press enter to continue.");
continueEnter = scnr.nextLine();
System.out.print("\033[H\033[2J");
System.out.flush();
/*-------------------------------------------------------------------------------------------------------------------------*/
// Sebastian's Question
System.out.println("QUESTION 6");
System.out.println("What's 9 + 10?");
System.out.println("A. 9");
System.out.println("B. 21");
System.out.println("C. 19");
System.out.println("D. 56");
answer = scnr.nextLine();
if (answer.equalsIgnoreCase("C")) {
numCorrect++;
System.out.println("Good job!");
} else if (answer.equalsIgnoreCase("B")) {
System.out.println("You are quite dense.");
} else {
System.out.println("Incorrect");
}
System.out.println("Press enter to continue.");
continueEnter = scnr.nextLine();
System.out.print("\033[H\033[2J");
System.out.flush();
/*-------------------------------------------------------------------------------------------------------------------------*/
// Bryan's question
System.out.println("QUESTION 7");
System.out.println("What year was Antelope Valley College founded");
System.out.println("A. 1929");
System.out.println("B. 2020");
System.out.println("C. 1895");
System.out.println("D. 1738");
answer = scnr.nextLine();
if (answer.equalsIgnoreCase("A")) {
numCorrect++;
System.out.println("GOOD STUFF! You have earned one sheckle dont spend it all in one place :)");
} else {
System.out.println("AVC is the best how did you get that wrong! No dinner for you tonight!");
}
System.out.println("Press enter to continue");
continueEnter = scnr.nextLine();
System.out.print("\033[H\033[2J");
System.out.flush();
/*-------------------------------------------------------------------------------------------------------------------------*/
// Jason's question
System.out.println("QUESTION 8");
System.out.println("Who is one of the people credited with inventing the Internet?");
System.out.println("A. Friedrich Nietzsche");
System.out.println("B. Nikola Tesla");
System.out.println("C. Robert Khan");
System.out.println("D. Clifford Stoll");
answer = scnr.nextLine();
if (answer.equalsIgnoreCase("C")) {
numCorrect++;
System.out.println("Correct. You must be pretty knowledgable!");
} else {
System.out.println("Really...? Okay...");
}
System.out.println("Press enter to continue");
continueEnter = scnr.nextLine();
System.out.print("\033[H\033[2J");
System.out.flush();
/*-------------------------------------------------------------------------------------------------------------------------*/
// Shelby's Question
System.out.println("QUESTION 9 \nTrue or False? \nA. True \nB. False\n C. Both");
answer = scnr.nextLine();
if (answer.equalsIgnoreCase("C")) {
numCorrect++;
System.out.println("This is the way.");
} else {
System.out.println("Ur Dogwater kid... get better");
} // tyler was here
System.out.println("Press enter to continue");
continueEnter = scnr.nextLine();
System.out.print("\033[H\033[2J");
System.out.flush();
/*-------------------------------------------------------------------------------------------------------------------------*/
// Frances' Second Question
System.out.println("QUESTION 10");
System.out.println("Who broke the sound barrier and when?");
System.out.println("A. Chuck Yeager; October 14, 1947");
System.out.println("B. Charles Lindbergh; May 21, 1927");
System.out.println("C. Jimmy Doolittle; April 18, 1942");
System.out.println("D. Howard Hughes; July 7, 1946");
answer = scnr.nextLine();
if (answer.equalsIgnoreCase("A")) {
numCorrect++;
System.out.println("HAHAHA NERD!!! You must really have an appreciation for military history! ");
} else {
System.out.println("I guess you're not a major history nerd then!");
}
System.out.println("Press enter to continue.");
continueEnter = scnr.nextLine();
System.out.print("\033[H\033[2J");
System.out.flush();
/*-------------------------------------------------------------------------------------------------------------------------*/
// Cristians Question
System.out.println("QUESTION 11");
System.out.println(
"A Few Good Men was a legal drama released in 1992, starring Tom Cruise, Jack Nicholson, and Demi Moore. This film centers around an alleged murder that takes place at a military base, so now I ask you which base?");
System.out.println("A. Naval Air Station Miramar");
System.out.println("B. Guantanamo Bay");
System.out.println("C. Langley Air Force Base");
System.out.println("D. Who is Tom Cruise?");
answer = scnr.nextLine();
if (answer.equalsIgnoreCase("B")) {
numCorrect++;
System.out.println("Correctamundo!! Fun Fact: This movie was actually based on a true story");
} else {
System.out.println("YOU CANT HANDLE THE TRUTH!!!!!");
}
System.out.println("Press enter to continue.");
continueEnter = scnr.nextLine();
System.out.print("\033[H\033[2J");
System.out.flush();
/*-------------------------------------------------------------------------------------------------------------------------*/
// System.out.println();
printEndScreen(numCorrect); // Excecutes method that prints the end screen
System.out.println("\nPress enter to end:");
continueEnter = scnr.nextLine();
scnr.close();
System.out.println("\nBye!!!");
} // End of Main
/*-------------------------------------------------------------------------------------------------------------------------*/
// End Screen Method
static void printEndScreen(int numCorrect) { // Definition of printEndScreen Method
String border = ""; // Declares string variable
String score = "Final Score: "; // Declares string variable
score += Integer.toString(numCorrect); // Adds number of correct answers into "Final Score" string
for (int i = 0; i < score.length(); ++i) { // Adjusts length of box to length of final score statement
border += "-";
}
// Outputs final score surrounded in a box graphic
System.out.println("+-" + border + "-+");
System.out.println("| " + score + " |");
System.out.println("+-" + border + "-+");
// Switch statement based on how many questions right
switch (numCorrect) {
case 0:
System.out.println("- Wow you got all wrong! Too bad! -");
break;
case 1:
case 2:
case 3:
case 4:
System.out.println("- You got " + numCorrect + " correct. Nice! -");
break;
case 5:
System.out.println("- You got half right! Good job! -");
break;
case 6:
case 7:
case 8:
case 9:
System.out.println("- You got " + numCorrect + " correct! Great job! -");
break;
case 10:
System.out.println("Wow you got " + numCorrect
+ " right, thats pretty good! But there are 11 questions... Darn! You were so close to being a perfect human being and being selected for our AVC super soldier program. But since you missed the test by only one you have to live the rest of your life as a boring normal person pondering on what your could have been... Sorry.");
case 11:
System.out.println(
"- Perfect!!! You are a perfect speicimen and have been selected for our AVC super solider program. All we need is just 5 more minutes of your time, your social-security number, bank account number, and your first and last name. Thank You! -");
break;
}
}
/*-------------------------------------------------------------------------------------------------------------------------*/
} // End of Main Class