-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoop2.java
More file actions
102 lines (49 loc) · 1.43 KB
/
Copy pathoop2.java
File metadata and controls
102 lines (49 loc) · 1.43 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
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
import java.util.Scanner;
class Question{
public String flower;
public String answerOfQuestion1 = "jasmine";
public Double answer;
public Double answerOfQuestion2 = 3.428;
public void checkAnswer(){
if ((flower == answerOfQuestion1) || (flower == "JASMINE"))
{
System.out.println("Your answer 1 is correct!!");
}
else{
System.out.println("your answer 1 is wrong");
}
}
}
class MultipleChoiceQuestion extends Question{
void MultipleChoiceQuestion(){
System.out.println("Qustion : 1");
System.out.println("What is the natioanl flower of Pakistn??");
System.out.println("options \n 1 : rose \n 2 : lilly \n 3 : jasmine\n");
Scanner s1 = new Scanner(System.in);
flower = s1.nextLine();
}
}
class NumericQuestion extends Question{
void NumericQuestion(){
Scanner s2 = new Scanner(System.in);
System.out.println("question : 2");
System.out.println("12 / 3.5 = ????");
answer = s2.nextDouble();
if ((answer == answerOfQuestion2) || (answer == 3.418))
{
System.out.println("Your answer 2 is right");
}
else{
System.out.println("your answer 2 is wrong");
}
}
}
class TestInheritance{
public static void main(String args[]){
NumericQuestion player1 = new NumericQuestion();
MultipleChoiceQuestion player2 = new MultipleChoiceQuestion();
player2.MultipleChoiceQuestion();
player1.NumericQuestion();
player1.checkAnswer();
}
}