@@ -11,8 +11,9 @@ double semesterFee, creditFee, admissionFee, otherFees;
1111
1212
1313
14- // Readfile buffer size and temporary text file name for output generation
14+ // Readfile buffer size, format text file and temporary text file name for output generation
1515#define BUFFER_SIZE 1024
16+ char FILE_NAME [] = "formats/format.txt" ;
1617char TEMP_FILE_NAME [] = "formats/temp.txt" ;
1718
1819
@@ -28,10 +29,20 @@ char D_DATABASE_NAME[] = "database/d_costing_chart.db";
2829
2930
3031// getwaiver function to calculate waiver based on SSC and HSC result for Undergraduate
31- void getwaiver (double SSC , double HSC )
32+ void getwaiver (double SSC , double HSC , char * department )
3233{
3334 // Waiver is given on lowest result.
3435 double Result = fmin (SSC , HSC );
36+
37+ // Initially sets waiver to zero for LLB, Pharmacy department, and lowest result under 3.50
38+ if (strcmp (department , "LLB" ) == 0 ||
39+ strcmp (department , "B_Pharm" ) == 0 ||
40+ Result < 3.50 )
41+ {
42+ waiver = 0 ;
43+ return ;
44+ }
45+
3546 if (Result > 5.00 )
3647 {
3748 waiver = 70.0 ;
@@ -55,10 +66,6 @@ void getwaiver(double SSC, double HSC)
5566 else if (Result >= 3.50 )
5667 {
5768 waiver = 10.0 ;
58- }
59- else
60- {
61- waiver = 0.0 ;
6269 }
6370}
6471
@@ -102,7 +109,7 @@ void replace_placeholder(char *buffer, const char *placeholder, const char *valu
102109// Display function to read output format from csv file and print output to user
103110void Display (ResultCallback callback )
104111{
105- FILE * fp = fopen ("formats/format.txt" , "r" );
112+ FILE * fp = fopen (FILE_NAME , "r" );
106113 if (fp == NULL )
107114 {
108115 perror ("Failed to open input file" );
@@ -161,7 +168,7 @@ void Display(ResultCallback callback)
161168// Display function for Diploma Holders
162169void D_Display (ResultCallback callback )
163170{
164- FILE * fp = fopen ("formats/D_format.txt" , "r" );
171+ FILE * fp = fopen (FILE_NAME , "r" );
165172 if (fp == NULL )
166173 {
167174 perror ("Failed to open input file" );
@@ -263,8 +270,7 @@ void getCalculated(const char *department, double SSC, double HSC, ResultCallbac
263270 credit = sqlite3_column_int (stmt , 4 );
264271 year = sqlite3_column_int (stmt , 5 );
265272 semester = sqlite3_column_int (stmt , 6 );
266-
267- getwaiver (SSC , HSC );
273+ getwaiver (SSC , HSC , department );
268274 const int waivercreditFee = creditFee * ((100.0 - waiver )/100.0 );
269275 TC = (credit * waivercreditFee ) + (semesterFee * semester ) + admissionFee + otherFees ;
270276 Display (callback ); // Pass the callback function as callback
0 commit comments