Showing posts with label term project in c. Show all posts
Showing posts with label term project in c. Show all posts

Wednesday, March 14, 2012

DEPARTMENTAL STORE



#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
FILE *fp,*ft;
char another,choice,itemcode[20];
struct store
{
char item_code[20];
char item_name[30];
int per_case_qty;
int case_qty;
int total_qty;
float per_unit_price;
float transport;
float vat;
float profit;
float octory;
float retail_price;
};
struct store s;
int a;
while(1)
{
clrscr();
gotoxy(10,10);
printf("1...Add Records");
gotoxy(10,12);
printf("2...Show Records");
gotoxy(10,14);
printf("3...Modify Records");
gotoxy(10,16);
printf("4...Delete Records");
gotoxy(10,18);
printf("0...EXIT\nENTER UR CHOICE");
fflush(stdin);
choice=getche();
switch(choice)
{
case '1':
fp=fopen("store.txt","w+");
if(fp==NULL)
{
puts("cannot open files");
exit(1);
}

fseek(fp,0,2);
another='y';       /*add*/
while(another =='y')
{
fseek(fp,0,2);
printf("\n Enter the item_code.....");
scanf("%s",&s.item_code);
printf("\n Enter the item_name.....");
scanf("%s",&s.item_name);
printf("\n Enter the per_case_qty.....");
scanf("%d",&s.per_case_qty);
printf("\n Enter the case_qty.....");
scanf("%d",&s.case_qty);
printf("\n Enter the total_qty.....");
s.total_qty=s.per_case_qty * s.case_qty;
printf("%d",s.total_qty);
printf("\n\n Enter the per_unit_price.....");
scanf("%f",&s.per_unit_price);
printf("\n Enter the transport.....");
scanf("%f",&s.transport);
printf("\n Enter the profit.....");
scanf("%f",&s.profit);
printf("\n Enter the vat.....");
scanf("%f",&s.vat);
printf("\n Enter the octory.....");
scanf("%f",&s.octory);
printf("\n Enter retail price.....");
s.retail_price=s.per_unit_price + s.transport + s.profit + s.vat + s.octory;
printf("%f",s.retail_price);
fwrite(&s,sizeof(s),1,fp);
fclose(fp);
printf("add another record (y/n)");
fflush(stdin);
another=getche();
}

break;

case '2':
fp=fopen("store.txt","r");
fseek(fp,0,0);
rewind(fp);
while(fread(&s,sizeof(s),1,fp)==1)
printf("\n itemcode" );
printf(" item_name");
//printf("\n per_case_qty");
//printf("\n case_qty");
printf(" total_qty");
//printf("\n per_unit_price");
printf(" transport");
printf(" profit");
printf("      vat");
//printf("\n octory");
printf("   retail_price");
a=fread(&s,sizeof(s),1,fp);
do
{
printf("\n %s",s.item_code);
printf("        %s",s.item_name);
//printf(" %d",s.per_case_qty);
//printf(" %d",s.case_qty);
printf("        %d",s.total_qty);
//printf(" %f",s.per_unit_price);
printf("       %f",s.transport);
printf("  %f",s.profit);
printf("  %f",s.vat);
//printf(" %f",s.octory);
printf("  %f",s.retail_price);

a=fread(&s,sizeof(s),1,fp);
}
while(a>0);
fclose(fp);
getch();
break;

case '3':
fp=fopen("store.txt","a+");
another='y';
while(another=='y')
{
printf("\n Enter the item_code of item to modify...");
scanf("%s",&itemcode);
rewind(fp);
while(fread(&s,sizeof(s),1,fp)==1)
{
if(strcmp(s.item_code,itemcode)==0)
{
printf("\n item_code....%s",s.item_code);
//scanf("%s",&s.item_code);
printf("\n item_name...%s",s.item_name);
//scanf("%s",&s.item_name);
printf("\n per_case_qty....");
scanf("%d",&s.per_case_qty);
printf("\n case_qty....");
scanf("%d",&s.case_qty);
printf("\n total_qty....");
s.total_qty=s.per_case_qty * s.case_qty;
printf("%d",s.total_qty);
printf("\n per_unit_price.....");
scanf("%f",&s.per_unit_price);
printf("\n transport.....");
scanf("%f",&s.transport);
printf("\n profit.....");
scanf("%f",&s.profit);
printf("\n vat.....");
scanf("%f",&s.vat);
printf("\n octory.....");
scanf("%f",&s.octory);
printf("\n retail price.....");
s.retail_price=s.per_unit_price + s.transport + s.profit + s.vat + s.octory;
printf("%f",s.retail_price);
fwrite(&s,sizeof(s),1,fp);
fclose(fp);
}
else
{
printf(" Record not found");
}
}
printf("\n Modify another records(Y/N)");
fflush(stdin);
another=getch();
}
break;
case '4':
fp=fopen("store.txt","r+");
another='y';
while(another=='y')
{
printf("\n Enter item_code of item to delete");
scanf("%s",&itemcode);
ft=fopen("temp.txt","w+");
rewind(fp);
while(fread(&s,sizeof(s),1,fp)==1)
{
if(strcmp(s.item_code,itemcode)==0)
fwrite(&s,sizeof(s),1,ft);
}
fclose(fp);
fclose(ft);
remove("STORE.txt");
rename("temp.txt","STORE.txt");
fp=fopen("STORE.txt","r+");
printf("delete another record(Y/N)");
fflush(stdin);
another=getche();
}
break;
case '0':
fclose(fp);
exit(0);
}
}
}

PAYROLL SYSTEM


#include<stdio.h>

#include<process.h>

#include<ctype.h>

#include<string.h>

#include<dos.h>

#include<conio.h>

#define PAUSE 10000



void addEmp();

void viewEmp();

void addDed();

void viewDed();

void exitSys();

void linefill(int start);



struct employee{

char code[10];

char fname[15];

char lname[15];

char mname[5];

char sex[10];

char status[15];

char ded_name1[15];

char ded_name2[15];

char ded_name3[15];

float grossPay;

float netPay;

float tax;

float ded_n1;

float ded_n2;

float ded_n3;

}empRec[50];



char ch,ID[10];

int x,cntrX,idCheck;



void main()

{

int start=16,end=20;



 
 
 
 
 
 
textattr(9+(1<<4)); clrscr(); cntrX=0;

while(1 == 1)

 {

 window(1,1,80,25);

 linefill(start); textattr(10+(1<<4));

 gotoxy(20,3); cprintf("Ûßßß Ü ÛßßÛ ÜÜÜÜ Û   ");

 gotoxy(20,4); cprintf("ÛÛßß Ü ÛÛ Û ÜÜÜÛ ÛÛ  ");

 gotoxy(20,5); cprintf("ÛÛ   Û ÛÛ Û ÛÜÜÛ ÛÛÜÜ");

 textattr(6+(1<<4));

 gotoxy(42,3); cprintf("Üßßßß Û   Û Üßßßß");

 gotoxy(42,4); cprintf(" ßßßÜ  ßÛß   ßßßÜ");

 gotoxy(42,5); cprintf("ßßßß    ß   ßßßß ");

 textattr(15+(1<<4));

 gotoxy(60,3); cprintf("TM ");

 gotoxy(23,7); cprintf("           Final Project           ");

 gotoxy(23,8); cprintf("         by: Joel Badinas          ");

 gotoxy(23,9); cprintf("           October 2001            ");

 textattr(2+(4<<4));

 gotoxy(29,14); cprintf(" >> M A I N  M E N U << ");

 textattr(2+(1<<4));

 gotoxy(25,15); cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");

 gotoxy(33,16); printf("Add new employee");

 gotoxy(33,17); printf("View employee");

 gotoxy(33,18); printf("Add deduction");

 gotoxy(33,19); printf("View deduction");

 gotoxy(33,20); printf("Quit");

 gotoxy(25,21); cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");

 textattr(14+(1<<4));

 gotoxy(2,25);  cprintf("FiNaLSYS Ver 1.0");

 gotoxy(63,25); cprintf("Copyright(c) 2001");

 ch=getch();

 if(ch==72)

  {

  textbackground(1); textcolor(9);

  gotoxy(31,start); cprintf("                    ");

  start = start -1;

  if(start < 16)

   {

   start = end;

   }

  textbackground(1); textcolor(9);

  gotoxy(31,start+1); cprintf("                    ");

  linefill(start);

  }

 if(ch==80)

  {

  textbackground(1); textcolor(9);

  gotoxy(31,start); cprintf("                    ");

  start = start + 1;

  if(start > 20)

   {

   start = 16;

   }

  textbackground(1); textcolor(9);

  gotoxy(31,start-1); cprintf("                    ");

  linefill(start);

  }

 if(ch == 13)

  {

  if(start == 16)

   {

   addEmp(); textattr(9+(1<<4));

   window(1,1,80,24); clrscr();

   }

  if(start == 17)

   {

   viewEmp(); textattr(9+(1<<4));

   window(1,1,80,24); clrscr();

   }

  if(start == 18)

   {

   addDed(); textattr(9+(1<<4));

   window(1,1,80,24); clrscr();

   }

  if(start == 19)

   {

   viewDed(); textattr(9+(1<<4));

   window(1,1,80,24); clrscr();

   }

  if(start == 20)

   {

   exitSys(); exit(0);

   }

  }

 }

}



void addEmp()

{

float pay1;

char name1[15],name2[15],name3[5],name4[10],name5[15];

ch=0;

while(ch != 'N')

 {

 window(8,4,72,22);

 textattr(2+(0<<4)); clrscr(); textattr(7+(0<<4));

 while(1 == 1)

  {

  idCheck=0;

  gotoxy(6,3); cprintf("Enter code     : "); scanf("%s",&ID);

  for(x=0;x<cntrX+1;x++)

   {

   if(strcmp(empRec[x].code,ID)==0)

    {

    idCheck=1;

    }

   }

  if(idCheck==1)

   {

   gotoxy(23,3); printf("                          ");

   gotoxy(2,19); cprintf("Code no. already exist!                        ");

   delay(PAUSE);

   gotoxy(2,19); printf("                                               ");

   }

  else

   {

   break;

   }

  }

 gotoxy(6,8);  cprintf("Last Name      : ");

 gotoxy(6,9);  cprintf("First Name     : ");

 gotoxy(6,10); cprintf("Middle Initial : ");

 gotoxy(6,11); cprintf("Sex            : ");

 gotoxy(6,12); cprintf("Status         : ");

 gotoxy(6,13); cprintf("Monthly Pay    : ");



 gotoxy(23,8);  scanf("%s",&name1);

 gotoxy(23,9);  scanf("%s",&name2);

 gotoxy(23,10); scanf("%s",&name3);

 gotoxy(23,11); scanf("%s",&name4);

 gotoxy(23,12); scanf("%s",&name5);

 gotoxy(23,13); scanf("%f",&pay1);

 gotoxy(2,19); cprintf("Save this entry? (Y/N)                           ");

 ch=0;

 while(ch != 'Y'&& ch != 'N')

  {

  ch=toupper(getch());

  }

 if(ch=='Y')

  {

  cntrX++;

  strcpy(empRec[cntrX].code,ID);

  strcpy(empRec[cntrX].fname,name1);

  strcpy(empRec[cntrX].lname,name2);

  strcpy(empRec[cntrX].mname,name3);

  strcpy(empRec[cntrX].sex,name4);

  strcpy(empRec[cntrX].status,name5);

  empRec[cntrX].grossPay = pay1;

  empRec[cntrX].tax = (.12)*pay1;

  empRec[cntrX].netPay = empRec[cntrX].grossPay-empRec[cntrX].tax;

  gotoxy(2,19); cprintf("Saving entry...                                 ");

  delay(PAUSE);

  }

 else

  {

  gotoxy(2,19); cprintf("Saving cancelled...                             ");

  delay(PAUSE);

  }

 gotoxy(2,19); cprintf("Save entry again? (Y/N)                          ");

 ch=0;

 while(ch != 'Y'&& ch != 'N')

  {

  ch=toupper(getch());

  }

 }

}



void viewEmp()

{

ch=0;

while(ch != 'N')

 {

 idCheck=0;

 window(8,4,72,22);

 textattr(2+(0<<4)); clrscr(); textattr(7+(0<<4));

 gotoxy(6,3); cprintf("Enter code     : "); scanf("%s",&ID);

 for(x=0;x<cntrX+1;x++)

  {

  if(strcmp(ID,empRec[x].code)==0)

   {

   gotoxy(6,8);  cprintf("Last Name      : ");

   gotoxy(6,9);  cprintf("First Name     : ");

   gotoxy(6,10); cprintf("Middle Initial : ");

   gotoxy(6,11); cprintf("Sex            : ");

   gotoxy(6,12); cprintf("Status         : ");

   gotoxy(6,13); cprintf("Net Pay        : ");



   gotoxy(23,8);  printf("%s",empRec[x].fname);

   gotoxy(23,9);  printf("%s",empRec[x].lname);

   gotoxy(23,10); printf("%s",empRec[x].mname);

   gotoxy(23,11); printf("%s",empRec[x].sex);

   gotoxy(23,12); printf("%s",empRec[x].status);

   gotoxy(23,13); printf("%.2f",empRec[x].netPay);

   idCheck=1; break;

   }

  }

 if(idCheck==0)

  {

  gotoxy(2,19); cprintf("Employee record not found...                 ");

  delay(PAUSE);

  }

 gotoxy(2,19); cprintf("View employee again? (Y/N)                    ");

 ch=0;

 while(ch != 'Y'&& ch != 'N')

  {

  ch=toupper(getch());

  }

 }

}



void addDed()

{

char nameded1[15],nameded2[15],nameded3[15];

float amount1,amount2,amount3;

ch=0;

while(ch != 'N')

 {

 window(8,4,72,22); idCheck=0;

 textattr(2+(0<<4)); clrscr(); textattr(7+(0<<4));

 gotoxy(3,2); cprintf("Enter code : "); scanf("%s",&ID);

 for(x=0;x<cntrX+1;x++)

  {

  if(strcmp(ID,empRec[x].code)==0)

   {

   idCheck=1;

   gotoxy(3,6);  cprintf("Name        : ");

   gotoxy(3,7);  cprintf("Monthly Pay : ");

   gotoxy(46,6); cprintf("Sex    : ");

   gotoxy(46,7); cprintf("Status : ");



   gotoxy(17,6); printf("%s %s %s",empRec[x].fname,empRec[x].lname,empRec[x].mname);

   gotoxy(17,7); printf("%.2f",empRec[x].grossPay);

   gotoxy(55,6); printf("%s",empRec[x].sex);

   gotoxy(55,7); printf("%s",empRec[x].status);



   gotoxy(16,10); cprintf(" Type of Deduction  ³  Amount");

   gotoxy(16,11); cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");

   gotoxy(17,12); cprintf("1)"); gotoxy(36,12); cprintf("³");

   gotoxy(17,13); cprintf("2)"); gotoxy(36,13); cprintf("³");

   gotoxy(17,14); cprintf("3)"); gotoxy(36,14); cprintf("³");



   gotoxy(20,12); scanf("%s",&nameded1);

   gotoxy(39,12); scanf("%f",&amount1);



   gotoxy(20,13); scanf("%s",&nameded2);

   gotoxy(39,13); scanf("%f",&amount2);



   gotoxy(20,14); scanf("%s",&nameded3);

   gotoxy(39,14); scanf("%f",&amount3);



   gotoxy(2,19); cprintf("Save this entry? (Y/N)                     ");

   ch=0;

   while(ch != 'Y'&& ch != 'N')

    {

    ch=toupper(getch());

    }

   if(ch == 'Y')

    {

    for(x=0;x<cntrX+1;x++)

     {

     strcpy(empRec[x].ded_name1,nameded1);

     strcpy(empRec[x].ded_name2,nameded2);

     strcpy(empRec[x].ded_name3,nameded3);

     empRec[x].ded_n1 = amount1;

     empRec[x].ded_n2 = amount2;

     empRec[x].ded_n3 = amount3;

     empRec[x].netPay = empRec[x].grossPay-empRec[x].tax-amount1-amount2-amount3;

     }

    gotoxy(2,19); cprintf("Saving entry...                             ");

    delay(PAUSE); break;

    }

   else

    {

    gotoxy(2,19); cprintf("Saving cancelled...                         ");

    delay(PAUSE); break;

    }

   }

  }

 if(idCheck==0)

  {

  gotoxy(2,19); cprintf("Employee record not found...                  ");

  delay(PAUSE);

  }

 gotoxy(2,19); cprintf("Add deduction again? (Y/N)                    ");

 ch=0;

 while(ch != 'Y'&& ch != 'N')

  {

  ch=toupper(getch());

  }

 }

}



void viewDed()

{

ch=0;

while(ch != 'N')

 {

 window(8,4,72,22); idCheck=0;

 textattr(2+(0<<4)); clrscr(); textattr(7+(0<<4));

 gotoxy(3,2); cprintf("Enter code : "); scanf("%s",&ID);

 for(x=0;x<cntrX+1;x++)

  {

  if(strcmp(ID,empRec[x].code)==0)

   {

   idCheck=1;

   gotoxy(3,5);  cprintf("Name        : ");

   gotoxy(3,6);  cprintf("Monthly Pay : ");

   gotoxy(46,5); cprintf("Sex    : ");

   gotoxy(46,6); cprintf("Status : ");



   gotoxy(17,5); printf("%s %s %s",empRec[x].fname,empRec[x].lname,empRec[x].mname);

   gotoxy(17,6); printf("%.2f",empRec[x].grossPay);

   gotoxy(55,5); printf("%s",empRec[x].sex);

   gotoxy(55,6); printf("%s",empRec[x].status);



   gotoxy(16,9);  cprintf(" Type of Deduction  ³  Amount");

   gotoxy(16,10);  cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");

   gotoxy(17,11);  cprintf("1)");

   gotoxy(17,12);  cprintf("2)");

   gotoxy(17,13);  cprintf("3)");

   gotoxy(17,14);  cprintf("4)");

   gotoxy(36,11);  cprintf("³");

   gotoxy(36,12);  cprintf("³");

   gotoxy(36,13);  cprintf("³");

   gotoxy(36,14);  cprintf("³");

   gotoxy(36,16);  cprintf("³");

   gotoxy(16,15);  cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");



   gotoxy(20,11); printf("Salary Tax");

   gotoxy(20,12); printf("%s",empRec[x].ded_name1);

   gotoxy(20,13); printf("%s",empRec[x].ded_name2);

   gotoxy(20,14); printf("%s",empRec[x].ded_name3);

   gotoxy(20,16); printf("Net Pay");



   gotoxy(39,11); printf("%.2f",empRec[x].tax );

   gotoxy(39,12); printf("%.2f",empRec[x].ded_n1 );

   gotoxy(39,13); printf("%.2f",empRec[x].ded_n2 );

   gotoxy(39,14); printf("%.2f",empRec[x].ded_n3 );

   gotoxy(39,16); printf("%.2f",empRec[x].netPay);

   }

  }

 if(idCheck==0)

  {

  gotoxy(2,19); cprintf("Employee record not found...                ");

  delay(PAUSE);

  }

 gotoxy(2,19); cprintf("View deduction again? (Y/N)                   ");

 ch=0;

 while(ch != 'Y'&& ch != 'N')

  {

  ch=toupper(getch());

  }

 }

}



void linefill(int start)

{

textattr(0+(7<<4));

gotoxy(31,start); cprintf("                    ");

}



void exitSys()

{

window(8,4,72,22);

textattr(7+(0<<4)); clrscr();

gotoxy(16,10); printf("Please wait while system exits... ");

delay(PAUSE);

}



RESULT MANAGEMENT SYSTEM


# include <stdio.h>
# include <conio.h>
# include <stdlib.h>
# include <string.h>

# define EMP_FILE "empdata.txt"
# define TMP_FILE "tmpdata.txt"

# define PWD "nitz\0"

int main(int, char**);
void welcome_message(void);
void get_password(void);
void main_menu(void);
void manage_student(void);
void add_student(void);
void delete_student(void);
void edit_student(void);
void search_student(void);
void student_menu(void);
void exit_message(void);

int main(int argc, char *argv[])
{
            char menuOpt;
            int isExit = 0;
            welcome_message();
            if(argc > 1)
            {
                        clrscr();
                        printf("%s : Start Up Error >>> ", argv[0]);
                        fflush(stdin);
                        getch();
                        return (EXIT_FAILURE);
            }
            get_password();
            do
            {
                        main_menu();
                        fflush(stdin);
                        menuOpt = (char)getch();
                        switch(menuOpt)
                        {
                                    case '1':
                                    {
                                                manage_student();
                                                break;
                                    }
                                    case '2':
                                    {
                                                isExit = 1;
                                                break;
                                    }
                                    default:
                                    {
                                                clrscr();
                                                printf("Invalid Option!");
                                                fflush(stdin);
                                                getch();
                                                break;
                                    }
                        }
            }while(isExit == 0);
            exit_message();
            fflush(stdin);
            getch();
    return (EXIT_SUCCESS);
}

void welcome_message(void)
{
            clrscr();
            printf("\t\t\t\t****WELCOME****\n\n");
            printf("\t\t\t\t**TO**\n\n");
            printf("\t\t    **NITZ RESULT MANAGEMENT SYSTEM**\n\n");
            printf("\n\n\n\n\n\n\n\nPlease press any key to continue");
            fflush(stdin);
            getch();
}

void main_menu(void)
{
            clrscr();
            printf("                MENU\n");
            printf("                ----\n");
            printf("     [1] : Manage Students Result\n");
            printf("     [2] : Exit\n\n");
            printf(" >>> ");
}

void manage_student(void)
{
            char menuOpt;
            int isExit = 0;
            do
            {
                        student_menu();
                        fflush(stdin);
                        menuOpt = (char)getch();
                        switch(menuOpt)
                        {
                                    case '1':
                                    {
                                                add_student();
                                                break;
                                    }
                                    case '2':
                                    {
                                                delete_student();
                                                break;
                                    }
                                    case '3':
                                    {
                                                edit_student();
                                                break;
                                    }
                                    case '4':
                                    {
                                                search_student();
                                                break;
                                    }
                                    case '5':
                                    {
                                                isExit = 1;
                                                fflush(stdin);
                                                break;
                                    }
                                    default:
                                    {
                                                clrscr();
                                                printf("Invalid Option!");
                                                getch();
                                    }
                        }
            }while(isExit == 0);
}

void add_student(void)
{
            char name[50];
            char branch[100];
            char grade[11];
            char id[5];
            float tmarks;
            float percentage;
            FILE *fp;
            fp = fopen(EMP_FILE, "a+");
            do
            {
                        fscanf(fp, "%[^/]%*c%[^/]%*c%[^/]%*c%[^/]%*c%f %f%*c", name, branch, grade, id, &tmarks, &percentage);
                        if(feof(fp))
                        {
                                    break;
                        }
            }while(!(feof(fp)));
            clrscr();
            printf("Name          : ");
            fflush(stdin);
            gets(name);
            printf("Branch        : ");
            fflush(stdin);
            gets(branch);
            printf("Grade         : ");
            fflush(stdin);
            gets(grade);
            printf("ID            : ");
            fflush(stdin);
            gets(id);
            printf("Total Marks   : ");
            fflush(stdin);
            scanf("%f", &tmarks);
            printf("Percentage    : ");
            fflush(stdin);
            scanf("%f", &percentage);
            fprintf(fp, "%s/%s/%s/%s/%.2f %.2f\n", name, branch, grade, id, tmarks, percentage);
            fflush(fp);
            fclose(fp);
            clrscr();
            printf("Done Entering New Record >>> ");
            getch();
}

void delete_student(void)
{
            char name[50];
            char branch[100];
            char grade[11];
            char id[5];
            char idDel[5];
            float tmarks;
            float percentage;
            FILE *fp1;
            FILE *fp2;
            fp1 = fopen(EMP_FILE, "r");
            fp2 = fopen(TMP_FILE, "w");
            clrscr();
            printf("Enter Student ID to Delete : ");
            fflush(stdin);
            gets(idDel);
            do
            {
                        fscanf(fp1, "%[^/]%*c%[^/]%*c%[^/]%*c%[^/]%*c%f %f%*c", name, branch, grade, id, &tmarks, &percentage);
                        if(feof(fp1))
                        {
                                    break;
                        }
                        if((strcmp(id, idDel)) != 0)
                        {
                                    fprintf(fp2, "%s/%s/%s/%s/%.2f %.2f\n", name, branch, grade, id, tmarks, percentage);
                        }
            }while(!(feof(fp1)));
            fflush(fp2);
            fclose(fp1);
            fclose(fp2);
            remove(EMP_FILE);
            rename(TMP_FILE, EMP_FILE);
            clrscr();
            printf("Done Deleting >>> ");
            fflush(stdin);
            getch();
}

void edit_student(void)
{
            char name[50];
            char branch[100];
            char grade[11];
            char id[5];
            char idEdit[5];
            float tmarks;
            float percentage;
            FILE *fp1;
            FILE *fp2;
            fp1 = fopen(EMP_FILE, "r");
            fp2 = fopen(TMP_FILE, "w");
            clrscr();
            printf("Enter student ID to Edit : ");
            fflush(stdin);
            gets(idEdit);
            do
            {
                        fscanf(fp1,"%[^/]%*c%[^/]%*c%[^/]%*c%[^/]%*c%f %f%*c", name, branch, grade, id, &tmarks, &percentage );
                        if(feof(fp1))
                        {
                                    break;
                        }
                        if((strcmp(id, idEdit)) == 0)
                        {
                                    clrscr();
                                    printf("Enter new total marks : ");
                                    fflush(stdin);
                                    scanf("%f", &tmarks);
                                    printf("Enter the new number percentage : ");
                                    fflush(stdin);
                                    scanf("%f", &percentage);
                        }
            fprintf(fp2, "%s/%s/%s/%s/%.2f %.2f\n", name, branch, grade, id, tmarks, percentage);
            }while(!(feof(fp1)));
            fflush(fp2);
            fclose(fp1);
            fclose(fp2);
            remove(EMP_FILE);
            rename(TMP_FILE, EMP_FILE);
            clrscr();
            printf("Done Editing >>> ");
            fflush(stdin);
            getch();
}

void search_student(void)
{
            char name[50];
            char branch[100];
            char grade[11];
            char id[5];
            char idSearch[5];
            float tmarks;
            float percentage;
            FILE *fp;
            fp = fopen(EMP_FILE, "r");
            clrscr();
            printf("Enter the Student ID to Search : ");
            fflush(stdin);
            gets(idSearch);
            do
            {
                        fscanf(fp, "%[^/]%*c%[^/]%*c%[^/]%*c%[^/]%*c%f %f%*c", name, branch, grade, id, &tmarks, &percentage);
                        if(feof(fp))
                        {
                                    break;
                        }
                        if((strcmp(id, idSearch)) == 0)
                        {
                                    clrscr();
                                    printf("Name              : %s\n", name);
                                    printf("Branch            : %s\n", branch);
                                    printf("Grade             : %s\n", grade);
                                    printf("ID                : %s\n", id);
                                    printf("Total Marks       : %.2f\n", tmarks);
                                    printf("Percentage        : %.2f\n\n", percentage);
                                    printf("Press ENTER to continue >>> ");
                                    fflush(stdin);
                                    getch();
                        }
            }while(!(feof(fp)));
            fclose(fp);
}
void get_password(void)
{
            char password[7];
            do
            {
                        clrscr();
                        printf("Enter Password >>> ");
                        fflush(stdin);
                        gets(password);
            }while((strcmp(password, PWD)) != 0);
}

void student_menu(void)
{
            clrscr();
            printf("               MENU\n");
            printf("               ----\n");
            printf("    [1] : Add Student\n");
            printf("    [2] : Delete Student\n");
            printf("    [3] : Edit Student\n");
            printf("    [4] : Search Student\n");
            printf("    [5] : Go Back\n\n");
            printf(" >>> ");
}

void exit_message(void)
{
            clrscr();
            printf("THANK YOU!\n");
            printf(">>> ");
}