-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student3.java
54 lines (44 loc) · 1.32 KB
/
Student3.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
class Student3 {
private String name;
private int ID;
private double GPA;
public Student3(String name, int ID, double GPA) {
this.name = name;
this.ID = ID;
this.GPA = GPA;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getID() {
return ID;
}
public void setID(int ID) {
this.ID = ID;
}
public double getGPA() {
return GPA;
}
public void setGPA(double GPA) {
this.GPA = GPA;
}
public void displayInfo() {
System.out.println("Name: " + name);
System.out.println("ID: " + ID);
System.out.println("GPA: " + GPA);
}
public static void main(String[] args) {
UndergraduateStudent undergrad = new UndergraduateStudent("John Doe", 1001, 3.5, 2);
GraduateStudent grad = new GraduateStudent("Jane Smith", 2001, 3.8, "Computer Science");
DoctoralStudent doc = new DoctoralStudent("Michael Johnson", 3001, 4.0, "Physics", "Quantum Mechanics");
System.out.println("Undergraduate Student:");
undergrad.displayInfo();
System.out.println("\nGraduate Student:");
grad.displayInfo();
System.out.println("\nDoctoral Student:");
doc.displayInfo();
}
}