Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/scholarship/ScholarshipCalculator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default function ScholarshipCalculator() {
const newGPA = calculateGPA(newMarks);
const newScholarship = calculateScholarship(
newGPA,
newMarks,
FORMULA_B_MIN,
FORMULA_B_MAX_MAPPING[course],
);
Expand Down Expand Up @@ -142,6 +143,7 @@ export default function ScholarshipCalculator() {
const newMarks = calculateMarksFromGPA(gpa);
const newScholarship = calculateScholarship(
gpa,
newMarks,
FORMULA_B_MIN,
FORMULA_B_MAX_MAPPING[course],
);
Expand Down
3 changes: 3 additions & 0 deletions src/components/scholarship/calculate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ export function calculateGPA(marks: Mark[]): number {
*/
export function calculateScholarship(
GPA: number,
marks: Mark[],
Bmin: number,
Bmax: number,
): number {
// If any C or D marks appear, return 0
if (marks.some((v) => v === "C" || v === "D")) return 0;
// Formula for scholarship
const S = Bmin + (Bmax - Bmin) * Math.pow((GPA - 2) / 3, 2.5);
// Round down to the nearest multiple of 100
Expand Down
Loading