You are on page 1of 5

/*

Student Record System - C implementation



Polytechnic University oI the Philippines
Mabini Campus, Sta. Mesa, Manila
College oI Computer Management and InIormation Technology

A Partial FulIillment oI the Subject
C Programming 1

This is a simple Student Record System in C
which uses Iile handling concepts.

Programmed by: Frederick Badion
BS CompSci 1st year (SY: 2K4-2K5)
Subject ProIessor: Mr. AlIred Pagalilawan
Programmer/Instructor -CCMIT

*/
#includestdio.h~
#includeconio.h~
#includestring.h~
#includedos.h~
#includestdlib.h~
#includectype.h~

FILE *Ip;

struct student
char snum|13|;
char Iname|20|;
char sname|20|;
char mi;
char ccode;
}record;

void Temp1(void);
void twolinebox(int x1,int y1,int x2,int y2)
int x,y;
gotoxy(x1,y1); printI("E"); //alt-201
gotoxy(x2,y1); printI(""); //alt-187
Ior(yy11;yy2;y)
gotoxy(x1,y); printI(""); //alt-186
gotoxy(x2,y); printI(""); //alt-186
}
gotoxy(x1,y2); printI("E"); //alt-200
gotoxy(x2,y2); printI("/"); //alt-188
Ior(xx11;xx2;x)
gotoxy(x,y1); printI("I"); //alt-205
gotoxy(x,y2); printI("I"); //alt-205
}
gotoxy(x11,y11);
}

void printxy(int x,int y,char string||)
gotoxy(x,y); printI("s",string);
}

void center(int y,char string||)
int x(80-strlen(string)1)/2;
gotoxy(x,y);printI("s",string);
}

void Create(void)
char opt;
center(21,"WARNING!!!");
center(22,"You are about to create a new Iile");
center(23,"This will erase all records in the Iile...");
center(24,"Are you sure you want to proceed?|Y/N| ");
optgetche(); opttoupper(opt);
iI(opt'Y')
IpIopen("Group4.txt","w");
center(24," ");
center(24,"File successIully created!");
}
getch();
Iclose(Ip);
}
void Add(void)
char opt;
IpIopen("Group4.txt","a");

clrscr();
Temp1();
gotoxy(19,8); scanI(" "); gets(record.snum);
gotoxy(19,10); scanI(" "); gets(record.Iname);
gotoxy(19,12); scanI(" "); gets(record.sname);
gotoxy(19,14); record.migetche(); record.mitoupper(record.mi);
gotoxy(19,16); record.ccodegetche();
record.ccodetoupper(record.ccode);
gotoxy(5,22); clreol(); printxy(79,22,"");
IprintI(Ip,"s s s c
c",record.snum,record.Iname,record.sname,record.mi,record.ccode);
gotoxy(5,21); clreol(); center(21,"Record successIully added!");
printxy(79,21,""); gotoxy(53,22); delay(1000);
center(22,"Press any key to go to main menu..."); getch();
Iclose(Ip);
}


void Temp1(void)
twolinebox(2,6,79,20);
twolinebox(2,20,79,24);
twolinebox(2,2,79,24);
center(4,"ADD RECORD");
printxy(6,8,"Student no: ");
printxy(6,10,"First Name: ");
printxy(6,12,"Last Name: ");
printxy(6,14,"Middle init:");
printxy(6,16,"Course code: ");
center(22,"Course code: |A|-CompSci, |B|-Ior InIoTech, |any
key|-Sevices");
gotoxy(19,7);
}

void List(void)
int count0,i,x0,page1,CS0,IT0,Serv0;

IpIopen("Group4.txt","r");


clrscr();
center(2,"Polytechnic University oI the Philippines");
center(3,"Sta. Mesa, Manila");
center(5,"College oI Computer Management and InIormation Technology");
printxy(10,7,"Record Student # Name
Course");
Ior(i1;i80;i) gotoxy(i,8); puts("I"); /*Alt-205*/ }

while(IscanI(Ip,"s s s c
c",&record.snum,&record.Iname,&record.sname,&record.mi,&record.ccode)!EO
F)
iI(count!0&&count50) printxy(5,23,"Press any key to
continue..."); getch(); x0;
Ior(i10;i24;i)gotoxy(1,i); clreol();}
page;
}
gotoxy(70,4); printI("Page d",page);
gotoxy(13,10x); printI("d",count1);
gotoxy(19,10x); printI("s",record.snum);
gotoxy(37,10x); printI("s, s
c.",record.sname,record.Iname,record.mi);
gotoxy(62,10x);
switch(record.ccode)
case 'A': printI("CompSci"); CS; break;
case 'B': printI("InIoTech"); IT; break;
deIault : printI("Services"); Serv; break;
}
x;
count;
}
printxy(25,17,"TOTAL");
gotoxy(15,18); printI("Comp Sci: d",CS);
gotoxy(15,19); printI("InIoTech: d",IT);
gotoxy(15,20); printI("Services: d",Serv);
printxy(5,23,"Press any key to go to main menu...");
getch();

Iclose(Ip);
}

void Quit(void)
clrscr();
twolinebox(2,2,79,24);
center(8,"PROGRAMMED");
center(9,"BY");
center(11,"Group 4");
center(13,"Badion, Frederick A.");
center(14,"Saosa, Emmanuel R.");
center(15,"Zamora, Sweet Joan J.");
delay(5000);
exit(1);
Iclose(Ip);
}

void Errmess(void)
sound(1000);
center(22,"Invalid Input!");
delay(1000);
nosound();
}


void main()
char choice;
do
clrscr();
twolinebox(29,6,51,8);
twolinebox(20,5,60,18);
twolinebox(2,20,79,25);
twolinebox(2,2,79,25);

center(7,"MAIN MENU");
printxy(30,9,"Press:");
printxy(30,11,"|A|-Create File");
printxy(30,12,"|B|-Add Record");
printxy(30,13,"|C|-List Record");
printxy(30,14,"|D|-Quit Program");
printxy(30,16,"Enter your choice..."); gotoxy(50,16);
choicegetch(); choicetoupper(choice);
switch(choice)
case 'A': Create(); break;
case 'B': Add(); break;
case 'C': List(); break;
case 'D': Quit(); break;
deIault: Errmess(); break;
}
}while(choice!'D');
}

You might also like