Skip to content

Commit 3da52e6

Browse files
Quiz.java
1 parent 6c5aa4c commit 3da52e6

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Quiz.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import java.util.*;
2+
3+
public class QuizApp {
4+
public static void main(String[] args) {
5+
String[] q = {"Capital of India?", "2 + 2 = ?"};
6+
String[][] opt = {{"Delhi", "Mumbai", "Chennai"}, {"3", "4", "5"}};
7+
int[] ans = {1, 2};
8+
9+
Scanner sc = new Scanner(System.in);
10+
int score = 0;
11+
12+
for (int i = 0; i < q.length; i++) {
13+
System.out.println(q[i]);
14+
for (int j = 0; j < 3; j++)
15+
System.out.println((j+1) + ". " + opt[i][j]);
16+
17+
System.out.print("Answer: ");
18+
if (sc.nextInt() == ans[i]) score++;
19+
}
20+
21+
System.out.println("Score = " + score);
22+
}
23+
}

0 commit comments

Comments
 (0)