-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trivia_Quiz.java
69 lines (60 loc) · 2.75 KB
/
Trivia_Quiz.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
/*
* Prajeet Bohara
* 12/14/2023
* P5: The Royal Bank of Java
*/
import java.util.*;
public class Trivia_Quiz {
public static void main(String[] args) {
Scanner scan = new Scanner (System.in);
int score = 0;
System.out.println("What is your name?");
String name = scan.nextLine();
System.out.println("Welcome to Trivia Quiz!");
System.out.println("Type 'yes' to start the quiz or 'no' to end");
String start = scan.nextLine();
if (start.equals("yes")){
System.out.println("1. Who is the chief scientist of the current AI company 'OpanAI'?");
System.out.println("a.Elon Musk \nb.Sam Altman \nc.Iliya \nd.Lex Fridman");
String answer_a = scan.nextLine();
System.out.println("2.What is the capital of Nepal?(Bonus = 2)");
System.out.println("a.Kathmandu \nb.Lake Charles \nc.Bhaktapur \nd.Gulariya");
String answer_b = scan.nextLine();
if (answer_a.equals("c")|| answer_a.equals("c.")){
score ++;
}
if (answer_b.equals("a")|| answer_b.equals("a.")){
score += 2;
}
scan.close();
}
else{
System.out.println("Thanks for stopping by!");
}
System.out.println("Thank you for playing trivia quiz "+name+
". Your total score is "+ score+".");
System.out.println("\nThe correct answers are:"
+ "\nQ.1 = c \nQ.2 =a");
}
}
//System.out.println("1. Who is the chief scientist of the current AI company 'OpanAI'?");
// System.out.println("a.Elon Musk \nb.Sam Altman \nc.Iliya \nd.Lex Fridman");
// String answer_a = scan.nextLine();
// if (answer_a.equals("a") || answer_a.equals("b")|| answer_a.equals("c")|| answer_a.equals("d")){
// score ++;
// System.out.println("What is the capital of Nepal?(Bonus = 2");
// System.out.println("a.Kathmandu \nb.Lake Charles \nc.Bhaktapur \nd.Gulariya");
// String answer_b = scan.nextLine();
// if (answer_b.equals("a")||answer_b.equals("b")||answer_b.equals("c")||answer_b.equals("d")){
// score += 2;
// System.out.println("Congratulations, "+name+" You scored "+score);
// }
// else{
// System.out.println("Wrong input. Please only type 'a' or 'a.'!");
// }
// }
// else{
// System.out.println("Wrong input. Please only type 'a' or 'a.'!");
// }
//
// }