-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquizProgramm.java
More file actions
58 lines (41 loc) · 1.65 KB
/
quizProgramm.java
File metadata and controls
58 lines (41 loc) · 1.65 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
package ApexDay1;
import java.util.Scanner;
public class quizProgramm {
public static void main(String[] args) {
String[] question={"1.WHO IS YOUR FATHER OF COMPUTER? ","2.WHO IS FATHER OF MATHS?","3.WHO IS FATHER OF YOU?"};
String[][] options={{"1.A","2.B","3.C","4.D"},
{"1,A","2.B","3.C","4.D"},
{"1,A","2.B","3.C","4.D"}};
int [] answers={1,2,3};
int score=0;
int guess;
Scanner scanner=new Scanner(System.in);
System.out.println("------------------------------------------");
System.out.println("QUIZ PROGRAM");
System.out.println("------------------------------------------");
System.out.println();
for (int i=0;i< question.length;i++){
System.out.print(question[i]);
System.out.println();
for(String option:options[i]){
System.out.println(option);
}
System.out.print("Enter guess: ");
guess= scanner.nextInt();
if(guess==answers[i]){
System.out.println("*************************");
System.out.println("CORRECT!");
System.out.println("*************************");
score++;
System.out.println();
}
else{
System.out.println("*************************");
System.out.println("WRONG!");
System.out.println("*************************");
}
}
System.out.println("Final score is : "+score);
scanner.close();
}
}