AcademicTranscripts is a command-line driven Java system for incremental construction and validation of a student's academic record. The program processes a sequential command stream and maintains a mutable transcript state, updating and printing results after each valid operation.
The system enforces strict input validation, bounded state constraints, and deterministic GPA computation.
public static void main(String[] args)The program interprets args as a linear instruction stream, where commands are executed in-order under a stateful transcript model.
declareMajor <MAJ>
args.length ≥ 2<MAJ>must satisfy department validity constraints
-
Missing argument:
Invalid declareMajor command. Major not provided. -
Invalid department:
Invalid major: <MAJ>
- Initializes transcript state with declared major
- Establishes major-specific aggregation domain
addGrade <DEPT> <GRADE> <CREDITS>
- Requires exactly 3 arguments
-
Missing parameters:
Invalid addGrade command. Department, grade, and/or credits not provided.
A department is valid iff:
[ |department| = 3 \land department \neq \emptyset ]
Valid grades form a finite ordered set:
[ {A, A-, B+, B, B-, C+, C, C-, D+, D, D-, F} ]
Each grade maps to a grade-point value via a deterministic function:
getGradePoints(String grade)[ credits \in {1,2,3,4} ]
Additionally:
[ \text{Current Semester Credits} \leq 18 ]
Cannot add grade. Maximum credits allowed per semester is 18.
The system maintains the following state variables:
| Variable | Description |
|---|---|
total_credits |
Cumulative credits across all semesters |
semester_credits |
Credits in current semester |
major_credits |
Credits within declared major |
GPA |
Global GPA |
semester_GPA |
GPA for current semester |
major_GPA |
GPA restricted to major |
major |
Declared department |
- Major must be declared
- Input must pass
isAddGradeValid(...)
- Validate department
- Validate grade
- Validate credits
- Check semester credit bound
-
Updates:
total_creditssemester_creditsGPAsemester_GPA
-
Conditional:
-
If
department == major:- Update
major_credits - Update
major_GPA
- Update
-
Grade added: <DEPT> <GRADE> <CREDITS>
-
Resets:
semester_credits ← 0semester_GPA ← 0
-
Preserves:
- Global GPA
- Total credits
- Major statistics
[ GPA = \frac{\sum (grade_points_i \cdot credits_i)}{\sum credits_i} ]
Implemented via:
getGpa(double gradePoints, int credits)getCurrentSemesterGPA(...)getMajorGPA(...)
All follow weighted average semantics.
==========
Total Credits: <int>
Overall GPA: <double>
Current Semester Credits: <int>
Current Semester GPA: <double>
Major: <string>
Major Credits: <int>
Major GPA: <double>
==========