-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.java
64 lines (56 loc) · 1.58 KB
/
Student.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
package Workshop.Sample;
import java.lang.Math;
public class Student extends Human {
int knowledge;
int marks;
Student(String name, int age) {
super(name, age);
knowledge = study();
marks = giveExam(knowledge);
}
Student() {
}
int study() {
int min = 0, max = 100;
int knowledge = min + (int) (Math.random() * ((max - min) + 1));
return knowledge;
}
int giveExam(int knowledge) {
int marks, min = 0, max = 9;
{
if (knowledge > 90) {
min = 90;
max = 100;
} else if (knowledge > 80) {
min = 80;
max = 89;
} else if (knowledge > 70) {
min = 70;
max = 79;
} else if (knowledge > 60) {
min = 60;
max = 69;
} else if (knowledge > 50) {
min = 50;
max = 59;
} else if (knowledge > 40) {
min = 40;
max = 49;
} else if (knowledge > 30) {
min = 30;
max = 39;
} else if (knowledge > 20) {
min = 20;
max = 29;
} else if (knowledge > 10) {
min = 10;
max = 19;
} else if (knowledge > 0) {
min = 0;
max = 9;
}
}
marks = min + (int) (Math.random() * ((max - min) + 1));
return marks;
}
}