503 c syntax error at end of input please help ..i cant spot any error out there ..
Code:
//Assignment sem2#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define CLASS_SIZE 7
void GPA_BillProcessingSystem();
void Student_Records_Maintenance();
void Add();
void Modify();
void Delete();
void Process_Examination_Report();
void Generate_Bill();
typedef struct{
char StudentId[30];
char Name[30];
char Gender;
char Programme[5];
int Year;
int Sem;
double Fees;
}StudentData;
StudentData data[CLASS_SIZE];
FILE *StudentRecord;
char conf, a1;
char ID[30];
int choice;
int i=0, count=0, a=0;
char NEWid[30];
char NEWname[30];
char NEWgender;
char NEWprogram[5];
int NEWyear;
int NEWsem;
double NEWfees;
///////MAIN
int main()
{
do{
system("cls");
printf(" ______ ______ ____ \n"
" | | | | | \n"
" | ___ |______| |____| \n"
" |______| | | | \n\n"
"\t\t GPA and Bill Processing System \n"
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
"\t[1] Student Records Maintenance\n"
"\t[2] Process Examination Report\n"
"\t[3] Generate Bill\n"
"\t[4] Exit\n\n"
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("CHOOESE Your Choice :) ");
scanf(" %d", &choice);
switch(choice)
{
case 1:
Student_Records_Maintenance();
break;
case 2:
Process_Examination_Report();
break;
case 3:
Generate_Bill();
break;
case 4:
system("exit");
default:
printf("INVALID =) !\n");
}
}while(choice!=4);
return 0;
}
//////////STUDENT RECORDS MAINTENANCE
void Student_Records_Maintenance()
{
do{
system("cls");
printf(" ______ ______ __ __ \n"
" | | | | \\ / | \n"
" |______ |______| | \\/ | \n"
" ______| | \\ | | \n\n"
"\t\t Student Records Maintenance\n"
"=================================\n"
"[1] ADD Student Record\n"
"[2] MODIFY Student Record\n"
"[3] DELETE Student Record\n"
"[4] Main Menu\n\n");
printf("CHOOSE Your Choice :) ");
scanf("%d", &choice);
switch(choice)
{
case 1:
Add();
break;
case 2:
Modify();
break;
case 3:
Delete();
break;
case 4:
main();
break;
default:
printf("INVALID =) !\n");
}
}while(choice!=4);
///////ADD STUDENT
void Add()
{
StudentRecord = fopen("StudentRecord.txt","a+");
if((StudentRecord = fopen("StudentRecord.txt","a+"))==NULL)
{
prinft("Cannot Open StudentRecord.txt file!\n");
exit(-1);
}
for(i=0 ; i<CLASS_SIZE ; i++)
do
{
system("cls");
printf(" ____ _____ _____ \n"
" | | | ) | ) \n"
" |____| | ) | ) \n"
" | | |_____) |_____) \n\n"
"\t\t ADD Student Records\n"
"###########################\n\n");
printf("Student ID : ");
scanf(" %s", data[i].StudentId);
fflush(stdin);
printf("Name : ");
scanf(" %[^\n]", data[i].Name);
fflush(stdin);
printf("Gender : ");
scanf(" %c", &data[i].Gender);
fflush(stdin);
printf("Programme : ");
scanf(" %s", data[i].Programme);
fflush(stdin);
printf("Year of Study : ");
scanf(" %d", &data[i].Year);
fflush(stdin);
printf("Semester : ");
scanf(" %d", &data[i].Sem);
fflush(stdin);
printf("Fees : ");
scanf(" %lf", &data[i].Fees);
fflush(stdin);
fprintf(StudentRecord, " %s | %[^\n] | %c | %s | %d | %d | %.2f \n", data[i].StudentId, data[i].Name, data[i].Gender, data[i].Programme, data[i].Year, data[i].Sem, data[i].Fees);
system("cls");
printf("More Record [Y/N] :? " );
scanf(" %c", &conf);
fflush(stdin);
count++;
}while(conf=='Y' || conf=='y');
fclose(StudentRecord);
for(a=0; a<30; a++)
{
_sleep(30);
printf("*");
}
printf("ADDED Student Record ^-^ !\n");
system("cls");
main();
}
///////MODIFY STUDENT
void Modify()
{
StudentRecord = fopen("StudentRecord.txt","r");
if(StudentRecord==NULL)
{
printf("NOT FOUND!!\n");
}
while(fscanf(StudentRecord, " %s", data[i].StudentId)!=EOF)
{
fscanf(StudentRecord, " %[^\n] | %c | %[^\n] | %d | %d | %.2f", data[i].Name, &data[i].Gender, data[i].Programme, &data[i].Year, &data[i].Sem, &data[i].Fees);
i++;
fflush(stdin);
}
fclose(StudentRecord);
system("cls");
printf("Enter Student's ID to search :) ");
scanf(" %s", ID);
for(i=0;i<CLASS_SIZE+count;i++)
{
if(strcmp(data[i].StudentId, ID)==0)
{
system("cls");
printf(" __ __ _____ _____ \n"
" | \\ / | ( ) | )\n"
" | \\/ | ( ) | )\n"
" | | (_____) |_____)\n\n"
"\t\t MODIFY Student Records\n"
"##############################\n\n");
printf("Student ID : ");
scanf(" %s", NEWid);
strcpy(data[i].StudentId, NEWid);
fflush(stdin);
printf("Student Name : ");
scanf(" %[^\n]", NEWname);
strcpy(data[i].Name, NEWname);
fflush(stdin);
printf("Gender : ");
scanf(" %c", &NEWgender);
data[i].Gender = NEWgender;
fflush(stdin);
printf("Programme : ");
scanf(" %s", NEWprogram);
strcpy(data[i].Programme, NEWprogram);
fflush(stdin);
printf("Year of Study : ");
scanf(" %d", &NEWyear);
data[i].Year = NEWyear;
fflush(stdin);
printf("Semester : ");
scanf(" %d", &NEWsem);
data[i].Sem = NEWsem;
fflush(stdin);
printf("Fees : ");
scanf(" %lf", &NEWfees);
data[i].Fees = NEWfees;
fflush(stdin);
system("cls");
for(a=0; a<30; a++)
{
_sleep(30);
printf(".");
}
printf("MODIFIED Student Record ^-^ !\n"
"==================================\n");
printf("Student ID :) %s \n", data[i].StudentId);
printf("Name :) %[^\n] \n", data[i].Name);
printf("Gender :) %c \n", data[i].Gender);
printf("Programme :) %s \n", data[i].Programme);
printf("Year of Study :) %d \n", data[i].Year);
printf("Semester :) %d \n", data[i].Sem);
printf("Fees :) %.2f \n", data[i].Fees);
fprintf(StudentRecord, " %s | %[^\n] | %c | %s | %d | %d | %.2f \n", data[i].StudentId, data[i].Name, data[i].Gender, data[i].Programme, data[i].Year, data[i].Sem, data[i].Fees);
}
else
{
for(a=0; a<30; a++);
{
_sleep(30);
printf(".");
}
printf("Data NOT Found!!");
system("cls");
main();
}
fclose(StudentRecord);
system("cls");
main();
}
/////// DELETE STUDENT
void Delete()
{
system("cls");
StudentRecord = fopen("StudentRecord.txt","r");
if(StudentRecord==NULL)
{
printf("NOT FOUND =) !\n");
}
while(fscanf(StudentRecord, "%s | %[^\n] | %c | %s | %d | %d | %lf", data[i].StudentId, data[i].Name, data[i].Gender, data[i].Programme, data[i].Year, data[i].Sem, data[i].Fees)!=EOF)
{
i++;
}
printf(" ______ ______ \n"
" | ) | | \n"
" | ) |______ | \n"
" |______) |______ |______ \n\n"
"\t\t DELETE Student Record\n"
"#############################\n\n");
printf("Enter Student's ID to Delete :) ");
scanf(" %s", ID);
fflush(stdin);
if(strcmp(data[i].StudentId, ID)==0)
{
//data[i].StudentId = '\0';
}
else
{
printf("INVALID =) !\n");
}
fclose(StudentRecord);
}
///////PROCESS EXAMINATION REPORT
void Process_Examination_Report()
{
char size[CLASS_SIZE][5]={0}, grade;
double avgGPA=0, GPA=0, highGPA=0, lowGPA=0, total=0, num, sum=0;
int index1=0, index=0, j=0;
system("cls");
printf(" ______ ______ ______ \n"
" | | | | | \n"
" |______| |______ |______| \n"
" | |______ | \\ \n\n"
"\t\t Process Examination Report \n"
"===================================\n\n");
for(i=0; i<CLASS_SIZE + count; i++) //for row
{
printf("Enter the Grade for Student Number %d =)\n", i+1);
for(j=0; j<CLASS_SIZE + count; j++) //for column
{
printf("Subject %d =) ", j+1);
scanf(" %c", &size[i][5]);
}
}
fflush(stdin);
printf(" ______ ______ _______ _______ _______ _______ \n"
" | | | | | ( ) | | | \n"
" |______| |______ |_______| ( ) |_______| | \n"
" | \\ |______ | (_______) | \\ | \n\n"
"\t\t Examination Report \n"
"===========================\n\n"
"Student No. \t\t Subject \n"
"\t\t\t| S1 | S2 | S3 | S4 | S5 | GPA | \n"
"\t\t\t|=====+======+======+======+======+=======| \n");
for(i=0; i<CLASS_SIZE + count; i++)
{
//total
printf("| %d |\n", i+1);
for(j=0; j<5; j++)
{
//num
printf("| %c |",size[i][5]);
total+=num;
num=(double)grade;
if(total<lowGPA)
{
lowGPA=total;
index=1;
}
if(total>highGPA)
{
highGPA=total;
index1=1;
}
printf("| %.2f |", total/5);
avgGPA = total/5;
printf("\nAverage GPA = %.2f \n", avgGPA / (CLASS_SIZE + count));
printf("Highest GPA = %.2f obtained by Student No %d \n", highGPA, index1);
printf("Lowest GPA = %.2f obtained by Student No %d \n", lowGPA, index);
switch(grade)
{
case 'A': case 'a':
printf("Grade Point = 4.0\n");
break;
case 'B': case 'b':
printf("Grade Point = 3.0\n");
break;
case 'C': case 'c':
printf("Grade Point = 2.0\n");
break;
case 'D': case'd':
printf("Grade Point = 1.0\n");
break;
case 'F': case 'f':
printf("Grade Point = 0.0\n");
break;
default:
printf("Error!\n");
}
}
///////GENERATE BILL
void Generate_Bill()
{
char programme[5];
double GPA, Fees, Bill, Sum;
FILE *BILL;
BILL = fopen("Bill.txt","w");
printf(" _______ _______ \n"
" | | | | | \n"
" |_______| | | | \n"
" |_______| ___|___ |_____ |_____ \n\n"
"\t\t Generate Bill \n"
"======================\n\n");
printf("Enter Your Programme :) ");
scanf(" %s", programme);
fflush(stdin);
printf("Enter Your Programme's Fees :) RM ");
scanf(" %lf", &Fees);
fflush(stdin);
printf("Enter Your GPA :) ");
scanf(" %lf", &GPA);
fflush(stdin);
if(GPA>=3.85)
{
Bill = Fees * 1.00;
Sum = Bill;
printf("ScholarShip 100%% ! RM%.2f \n", Sum);
}
else if(GPA>=3.75)
{
Bill = Fees * 0.75;
Sum = Bill;
printf("ScholarShip 75%% ! RM%.2f \n", Sum);
}
else if(GPA>=3.65)
{
Bill = Fees * 0.50;
Sum = Bill;
printf("ScholarShip 50%% ! RM%.2f \n", Sum);
}
else
{
Bill = Fees;
Sum = Bill;
printf("ScholarShip NOT available..Thank You =) !\n");
}
fprintf(BILL, "|BBBBBB IIIIII LLLLLL LLLLLLL|\n");
fprintf(BILL, "|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|\n");
fprintf(BILL, "|Programme | %s |\n", programme);
fprintf(BILL, "|Programme Fees | RM %.2f |\n", Fees);
fprintf(BILL, "|ScholarShip | %.2f |\n", Bill);
fprintf(BILL, "|Sum | RM %.2f |\n", Sum);
fprintf(BILL, "|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|\n");
}
Keep showing syntax error at the end of input ...but i cant find any it ..