-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReflectionStudent.java
More file actions
84 lines (73 loc) · 1.52 KB
/
ReflectionStudent.java
File metadata and controls
84 lines (73 loc) · 1.52 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
package reflection;
public class ReflectionStudent implements ReflectionInterface {
private int roll;
private String name;
private double marks;
private final double total = 500;
char grade;
// constructor
public ReflectionStudent(int roll, String name, double marks) {
this.roll = roll;
this.name = name;
this.marks = marks;
}
// getters and setters
public int getRoll() {
return roll;
}
public void setRoll(int roll) {
this.roll = roll;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getMarks() {
return marks;
}
public void setMarks(double marks) {
this.marks = marks;
}
// methods
private double calculatePercentage() {
return getMarks()/total;
}
public char calculateGrade() {
double perc = calculatePercentage();
if (perc >=91 && perc <= 100) {
return 'O';
}
else if (perc >=81 && perc <= 90) {
return 'E';
}
else if (perc >=71 && perc <= 80) {
return 'A';
}
else if (perc >=61 && perc <= 70) {
return 'B';
}
else if (perc >=51 && perc <= 60) {
return 'C';
}
else if (perc >=41 && perc <= 50) {
return 'D';
}
else if (perc >=0 && perc <= 40) {
return 'F';
}
else {
return 'K';
}
}
public static void main(String[] args) {
ReflectionStudent reflectionStudent = new ReflectionStudent(01,"cdsd",565);
System.out.println(reflectionStudent.toString());
}
@Override
public void display() {
// TODO Auto-generated method stub
System.out.println("hello");
}
}