-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScienceStudent.java
43 lines (35 loc) · 1.32 KB
/
ScienceStudent.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
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;
public class ScienceStudent extends Student {
// Private fields to store Science student grades
private double attendanceGrade;
private double projectGrade;
private double midtermGrade;
private double finalExamGrade;
// Constructor to initialize student data and Science student grades
public ScienceStudent(String firstName, String lastName, double attendanceGrade, double projectGrade, double midtermGrade, double finalExamGrade) {
super(firstName, lastName, "Science");
this.attendanceGrade = attendanceGrade;
this.projectGrade = projectGrade;
this.midtermGrade = midtermGrade;
this.finalExamGrade = finalExamGrade;
}
// Public getter methods to access Science student grades from outside the class
public double getAttendanceGrade() {
return attendanceGrade;
}
public double getProjectGrade() {
return projectGrade;
}
public double getMidtermGrade() {
return midtermGrade;
}
public double getFinalExamGrade() {
return finalExamGrade;
}
// Public method to calculate and return the student's final average
public double calculateAverage() {
return (attendanceGrade * 0.1) + (projectGrade * 0.3) + (midtermGrade * 0.3) + (finalExamGrade * 0.3);
}
}