Package com.project
Enum Class GradeCalculator.Grades
- All Implemented Interfaces:
Serializable
,Comparable<GradeCalculator.Grades>
,Constable
- Enclosing class:
GradeCalculator
Enum representing the grade system based on marks ranges.
Each grade has a minimum and maximum mark range.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum Constants -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Grades
(double minMarks, double maxMarks) Constructor to initialize the grade range. -
Method Summary
Modifier and TypeMethodDescription(package private) static GradeCalculator.Grades
getGrade()
Determines the grade based on the calculated average marks.static GradeCalculator.Grades
Returns the enum constant of this class with the specified name.static GradeCalculator.Grades[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
A
Grade A: 91 - 100 marks. -
B
Grade B: 81 - 90 marks. -
C
Grade C: 71 - 80 marks. -
D
Grade D: 61 - 70 marks. -
E
Grade E: 51 - 60 marks.
-
-
Field Details
-
minMarks
final double minMarksThe minimum marks required for the grade. -
maxMarks
final double maxMarksThe maximum marks allowed for the grade.
-
-
Constructor Details
-
Grades
private Grades(double minMarks, double maxMarks) Constructor to initialize the grade range.- Parameters:
minMarks
- The minimum marks required for the grade.maxMarks
- The maximum marks allowed for the grade.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getGrade
Determines the grade based on the calculated average marks.- Returns:
- The grade corresponding to the average marks, or
null
if no grade matches.
-