-
Notifications
You must be signed in to change notification settings - Fork 0
/
MathStudent.java
44 lines (35 loc) · 1.26 KB
/
MathStudent.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
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;
public class MathStudent extends Student {
// Private fields to store Math student grades
private double quizAverage;
private double test1Grade;
private double test2Grade;
private double finalExamGrade;
// Constructor to initialize student data and Math student grades
public MathStudent(String firstName, String lastName, double quizAverage, double test1Grade, double test2Grade, double finalExamGrade) {
super(firstName, lastName, "Math");
this.quizAverage = quizAverage;
this.test1Grade = test1Grade;
this.test2Grade = test2Grade;
this.finalExamGrade = finalExamGrade;
}
// Public getter methods to access Math student grades from outside the class
public double getQuizAverage() {
return quizAverage;
}
public double getTest1Grade() {
return test1Grade;
}
public double getTest2Grade() {
return test2Grade;
}
public double getFinalExamGrade() {
return finalExamGrade;
}
// Public method to calculate and return the student's final average
public double calculateAverage() {
return (quizAverage * 0.15) + (test1Grade * 0.3) + (test2Grade * 0.2) + (finalExamGrade * 0.35);
}
}