@@ -11,8 +11,9 @@ double semesterFee, creditFee, admissionFee, otherFees;
11
11
12
12
13
13
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
15
15
#define BUFFER_SIZE 1024
16
+ char FILE_NAME [] = "formats/format.txt" ;
16
17
char TEMP_FILE_NAME [] = "formats/temp.txt" ;
17
18
18
19
@@ -28,10 +29,20 @@ char D_DATABASE_NAME[] = "database/d_costing_chart.db";
28
29
29
30
30
31
// 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 )
32
33
{
33
34
// Waiver is given on lowest result.
34
35
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
+
35
46
if (Result > 5.00 )
36
47
{
37
48
waiver = 70.0 ;
@@ -55,10 +66,6 @@ void getwaiver(double SSC, double HSC)
55
66
else if (Result >= 3.50 )
56
67
{
57
68
waiver = 10.0 ;
58
- }
59
- else
60
- {
61
- waiver = 0.0 ;
62
69
}
63
70
}
64
71
@@ -102,7 +109,7 @@ void replace_placeholder(char *buffer, const char *placeholder, const char *valu
102
109
// Display function to read output format from csv file and print output to user
103
110
void Display (ResultCallback callback )
104
111
{
105
- FILE * fp = fopen ("formats/format.txt" , "r" );
112
+ FILE * fp = fopen (FILE_NAME , "r" );
106
113
if (fp == NULL )
107
114
{
108
115
perror ("Failed to open input file" );
@@ -161,7 +168,7 @@ void Display(ResultCallback callback)
161
168
// Display function for Diploma Holders
162
169
void D_Display (ResultCallback callback )
163
170
{
164
- FILE * fp = fopen ("formats/D_format.txt" , "r" );
171
+ FILE * fp = fopen (FILE_NAME , "r" );
165
172
if (fp == NULL )
166
173
{
167
174
perror ("Failed to open input file" );
@@ -263,8 +270,7 @@ void getCalculated(const char *department, double SSC, double HSC, ResultCallbac
263
270
credit = sqlite3_column_int (stmt , 4 );
264
271
year = sqlite3_column_int (stmt , 5 );
265
272
semester = sqlite3_column_int (stmt , 6 );
266
-
267
- getwaiver (SSC , HSC );
273
+ getwaiver (SSC , HSC , department );
268
274
const int waivercreditFee = creditFee * ((100.0 - waiver )/100.0 );
269
275
TC = (credit * waivercreditFee ) + (semesterFee * semester ) + admissionFee + otherFees ;
270
276
Display (callback ); // Pass the callback function as callback
0 commit comments