-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuiz.java
More file actions
52 lines (40 loc) · 1.58 KB
/
Quiz.java
File metadata and controls
52 lines (40 loc) · 1.58 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
import java.util.Scanner;
public class Quiz {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("1. Which country held the 2016 Summer Olympics?");
System.out.println("\ta) China\n\tb) Ireland\n\tc) Brazil\n\td) Italy\n");
String answer1 = scan.next();
System.out.println("\n2. Which planet is the hottest?");
System.out.println("\ta) Venus\n\tb) Saturn\n\tc) Mercury\n\td) Mars\n");
String answer2 = scan.next();
System.out.println("\n3. What is the rarest blood type?");
System.out.println("\ta) O\n\tb) A\n\tc) B\n\td) AB-Negative\n");
String answer3 = scan.next();
System.out.println("\n4. Which one of these characters is friends with Harry Potter?");
System.out.println("\ta) Ron Weasley\n\tb) Hermione Granger\n\tc) Draco Malfoy\n");
String answer4 = scan.next();
int score = 0;
if (answer1.equals("c")) {
score += 5;
}
if (answer2.equals("a")) {
score += 5;
}
if (answer3.equals("d")) {
score += 5;
}
if (answer4.equals("a") || answer4.equals("b")) {
score += 5;
}
System.out.println("Your final score is: " + score + "/20");
if (score >= 15) {
System.out.println("Wow, you know your stuff!");
} else if (score >= 5) {
System.out.println("Not bad!");
} else {
System.out.println("Better luck next time!");
}
scan.close();
}
}