-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPGStudent.java
More file actions
28 lines (24 loc) · 826 Bytes
/
Copy pathPGStudent.java
File metadata and controls
28 lines (24 loc) · 826 Bytes
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
// Postgraduate student class
// Inherits from Student and implements calculateGrade() based on PG rules
public class PGStudent extends Student {
// Constructor calls base class constructor to initialize fields
public PGStudent(String name, int rollNo, int marks) {
super(name, rollNo, marks);
}
// Calculate grade for PG student
@Override
public char calculateGrade() {
if (marks >= 90) return 'A';
else if (marks >= 75) return 'B';
else if (marks >= 60) return 'C';
else return 'F';
}
// Display PG student details
@Override
public void display() {
System.out.println("PG Student | Name: " + name +
" Roll: " + rollNo +
" Marks: " + marks +
" Grade: " + calculateGrade());
}
}