Skip to content

Commit 3212ecc

Browse files
Documentation updated and small changes made
1 parent 4be5498 commit 3212ecc

File tree

4 files changed

+80
-8
lines changed

4 files changed

+80
-8
lines changed
-1.28 MB
Binary file not shown.

NUB Admission Costing Calculator/docs/test.txt

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@ typedef void (*ResultCallback)(const char *)
1111
NOTE: This type definition allows for greater flexibility and modularity in the code by enabling functions
1212
to accept different callback implementations that conform to the specified signature.
1313

14-
void getwaiver(float SSC, float HSC)
15-
- Determines the waiver percentage based on the lower of two results between SSC and HSC.
16-
- Result higher than than 5.0 is kept for GOLDEN GPA 5.
14+
void getwaiver(double SSC, double HSC, const char *department)
15+
- Determines the lower of the SSC and HSC results.
16+
- Checks if the department is "LLB" or "B_Pharm" or if the lowest result is below 3.50:
17+
- Sets waiver to 0 if any of these conditions are met.
18+
- Sets waiver based on the lower of the SSC and HSC results:
19+
- If the result is greater than 5.00, sets waiver to 70 (which is for GOLDEN GPA 5)
20+
- If the result is equal to 5.00, sets waiver to 40
21+
- If the result is between 4.80 and 4.99 (inclusive), sets waiver to 30
22+
- If the result is between 4.50 and 4.79 (inclusive), sets waiver to 20
23+
- If the result is between 4.00 and 4.49 (inclusive), sets waiver to 15
24+
- If the result is between 3.50 and 3.99 (inclusive), sets waiver to 10
1725

1826
NOTE: The function calculates waivers based on academic performance,
1927
incentivizing higher scores with greater financial discounts.
@@ -63,17 +71,81 @@ NOTE: This function is similar to `Display` but uses a different format file ("f
6371
It ensures safe data processing and storage before passing it to the callback, avoiding data
6472
corruption or loss during processing.
6573

74+
void getCalculated(const char *department, double SSC, double HSC, ResultCallback callback)
75+
- Opens a connection to the database defined by DATABASE_NAME.
76+
- Handles errors if the database cannot be opened.
77+
- Constructs a SQL query to retrieve cost data for the specified department from the CostingChart table.
78+
- Prepares the SQL statement for execution.
79+
- Handles errors if the SQL statement fails to execute.
80+
- Executes the SQL statement and checks if the department was found.
81+
- Retrieves data from the resulting row:
82+
- SemesterFee
83+
- CreditFee
84+
- AdmissionFee
85+
- OtherFees
86+
- TotalCredits
87+
- Duration
88+
- Semesters
89+
- Calls the getwaiver function to calculate the waiver based on SSC and HSC scores and department.
90+
- Calculates the total cost (TC) using the retrieved data and calculated waiver.
91+
- Calls the Display function with the provided callback function to display the results.
92+
- Resets all variables to 0.
93+
- Finalizes the SQL statement and closes the database connection.
94+
95+
void D_getCalculated(const char *department, double DiplomaResult, ResultCallback callback)
96+
- Opens a connection to the database defined by D_DATABASE_NAME.
97+
- Handles errors if the database cannot be opened.
98+
- Constructs a SQL query to retrieve cost data for the specified department from the D_CostingChart table.
99+
- Prepares the SQL statement for execution.
100+
- Handles errors if the SQL statement fails to execute.
101+
- Executes the SQL statement and checks if the department was found.
102+
- Retrieves data from the resulting row:
103+
- CreditFee
104+
- SemesterFee
105+
- OtherFees
106+
- AdmissionFee
107+
- Duration
108+
- Calls the D_getwaiver function to determine waiver eligibility based on the DiplomaResult:
109+
- If eligible, retrieves:
110+
- TotalCredit
111+
- Semester
112+
- If not eligible, retrieves:
113+
- TotalCreditBelow
114+
- SemesterBelow
115+
- Calculates the total cost (TC) using the retrieved data.
116+
- Calls the D_Display function with the provided callback function to display the results.
117+
- Resets all variables to 0.
118+
- Finalizes the SQL statement and closes the database connection.
119+
66120
------------------------------------------------------------------------------------------------------------------------------
67121

68122
------------------------------------------------------------test.c------------------------------------------------------------
69123

70-
int waiver, TC, year, semester, credit
124+
double waiver, int TC, year, semester, credit,
71125
- These global variables are used throughout the program to store and manipulate data related to academic programs.
72126

127+
double semesterFee, creditFee, admissionFee, otherFees
128+
- These global variables are used to read data from database.
129+
73130
#define BUFFER_SIZE 1024
74131
- Defines a global macro for the buffer size used when reading from files. It sets the size of the buffer to 1024 bytes.
75132

76-
char TEMP_FILE_NAME[] = "formats/temp.txt";
77-
- Declares a global array of characters that stores the name of the temporary file used during output generation.
133+
char FILE_NAME[] = "formats/D_formate.txt"
134+
- Declares a global array of characters that stores the path of the output format for undergraduate.
135+
136+
char D_FILE_NAME[] = "formats/D_formate.txt"
137+
- Declares a global array of characters that stores the path of the output format for diploma holders.
138+
139+
char TEMP_FILE_NAME[] = "formats/temp.txt"
140+
- Declares a global array of characters that stores the path of the temporary file used during output generation.
141+
142+
#define ROW_BUFFFER_SIZE 256
143+
- Defines a global macro for the buffer size used when retrieving data from a row of database.
144+
145+
char DATABASE_NAME[] = "database/costing_chart.db"
146+
- Declares a global array of characters that stores the path of the database for undergraduate.
147+
148+
char D_DATABASE_NAME[] = "database/d_costing_chart.db"
149+
- Declares a global array of characters that stores the path of the database for diploma holders.
78150

79151
------------------------------------------------------------------------------------------------------------------------------

NUB Admission Costing Calculator/main

-1.29 MB
Binary file not shown.

NUB Admission Costing Calculator/test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ double semesterFee, creditFee, admissionFee, otherFees;
1111

1212

1313

14-
// Readfile buffer size, format text file and temporary text file name for output generation
14+
// Readfile buffer size, format text files and temporary text file name for output generation
1515
#define BUFFER_SIZE 1024
1616
char FILE_NAME[] = "formats/format.txt";
1717
char D_FILE_NAME[] = "formats/D_format.txt";
@@ -20,7 +20,7 @@ char TEMP_FILE_NAME[] = "formats/temp.txt";
2020

2121

2222

23-
// Database row buffer size and file path
23+
// Database row buffer size and file paths
2424
#define ROW_BUFFFER_SIZE 256
2525
char DATABASE_NAME[] = "database/costing_chart.db";
2626
char D_DATABASE_NAME[] = "database/d_costing_chart.db";

0 commit comments

Comments
 (0)