More Related Content
Similar to Zoo management adri jovin
Similar to Zoo management adri jovin (20)
More from Adri Jovin (20)
Zoo management adri jovin
- 1. #include<stdio.h><br /> #include<conio.h><br /> #include<dos.h><br /> #include<string.h><br /> void main()<br /> {<br /> int iCh1,iInc;<br /> e:<br /> clrscr();<br /> /* To Display Main menu */<br /> gotoxy(26,40);<br /> textcolor(9);<br /> cprintf(quot;
SOFTWARE ENGINEERING PROJECTquot;
);<br /> gotoxy(32,44);<br /> textcolor(19);<br /> cprintf(quot;
BATCH-1(2006-07)quot;
);<br /> gotoxy(23,42);<br /> cprintf(quot;
ZOO MANAGEMENT SYSTEM ( ZMS-2007)quot;
);<br /> gotoxy(8,45);<br /> textcolor(9);<br /> /* To Dispaly date and time */<br /> cprintf(quot;
DATE : %s quot;
,__DATE__);<br /> gotoxy(55,45);<br /> cprintf(quot;
TIME : %s quot;
,__TIME__);<br /> for(iInc=0;iInc<=30;iInc++)<br /> {<br /> gotoxy(20,iInc);<br /> textcolor(7);<br /> cprintf(quot;
-quot;
);<br /> }<br /> for(iInc=0;iInc<80;iInc++)<br /> {<br /> gotoxy(iInc,30);<br /> textcolor(7);<br /> cprintf(quot;
|quot;
);<br /> }<br /> gotoxy(30,8);<br /> textcolor(9);<br /> /* Main menu */<br /> cprintf(quot;
ZOO MANAGEMENT SYSTEM (ZMS-2007)quot;
);<br /> gotoxy(30,10);<br /> textcolor(19);<br /> cprintf(quot;
1.ANIMALquot;
);<br /> gotoxy(30,12);<br /> cprintf(quot;
2.BIRDquot;
);<br /> gotoxy(30,14);<br /> cprintf(quot;
3.EXITquot;
);<br /> gotoxy(30,18);<br /> textcolor(9);<br /> cprintf(quot;
ENTER YOUR CHOICE:quot;
);<br /> scanf(quot;
%dquot;
,&iCh1);<br /> if<br /> (iCh1==3)<br /> {<br /> /* To exit from the system */<br /> gotoxy(30,28);<br /> textcolor(4);<br /> cprintf(quot;
SYSTEM SHUTTING DOWNquot;
);<br /> sleep(3);<br /> gotoxy(26,40);<br /> printf(quot;
SOFTWARE ENGINEERING PROJECTquot;
);<br /> gotoxy(8,42);<br /> printf(quot;
ZOO MANAGEMENT SYSTEM ( ZMS-2007)quot;
);<br /> gotoxy(8,45);<br /> printf(quot;
DATE : %s quot;
,__DATE__);<br /> gotoxy(55,45);<br /> printf(quot;
TIME : %s quot;
,__TIME__);<br /> exit(0);<br /> }<br /> else{<br /> /* Declarations of Variables */<br /> FILE *fp,*ft;<br /> char cAns,cChoice;<br /> struct zoo<br /> {<br /> char offspr[2],anim_history[50],an_name[30],keeper_nm[20],cellid[4],an_sex[2];<br /> int anim_age,offno;<br /> float wt,offrat,inbreed,food_s,food_c;<br /> };<br /> struct zoo e;<br /> char cell_id[4];<br /> int iF=0,iC=0,iF1=0;<br /> long int lRecsize;<br /> fp=fopen(quot;
zm.datquot;
,quot;
rb+quot;
);<br /> if(fp==NULL)<br /> {<br /> fp=fopen(quot;
m.datquot;
,quot;
wb+quot;
);<br /> if(fp==NULL)<br /> {<br /> puts(quot;
Cannot Open filequot;
);<br /> exit();<br /> }<br /> }<br /> lRecsize=sizeof(e);<br /> while(1)<br /> {<br /> clrscr();<br /> textcolor(4);<br /> if(iCh1==1) {<br /> gotoxy(30,8);<br /> textcolor(4);<br /> cprintf(quot;
ANIMAL MENUquot;
); }<br /> else if(iCh1==2) {<br /> gotoxy(30,8);<br /> textcolor(4);<br /> cprintf(quot;
BIRD MENUquot;
); }<br /> gotoxy(26,40);<br /> textcolor(4);<br /> cprintf(quot;
SOFTWARE ENGINEERING PROJECTquot;
);<br /> gotoxy(32,44);<br /> textcolor(19);<br /> cprintf(quot;
BATCH-1(2006-07)quot;
);<br /> gotoxy(23,42);<br /> textcolor(19);<br /> cprintf(quot;
ZOO MANAGEMENT SYSTEM ( ZMS-2007 )quot;
);<br /> gotoxy(8,45);<br /> textcolor(4);<br /> cprintf(quot;
DATE : %s quot;
,__DATE__);<br /> gotoxy(55,45);<br /> cprintf(quot;
TIME : %s quot;
,__TIME__);<br /> for(iInc=0;iInc<=30;iInc++)<br /> {<br /> gotoxy(20,iInc);<br /> textcolor(7);<br /> cprintf(quot;
-quot;
);<br /> }<br /> for(iInc=0;iInc<=80;iInc++)<br /> {<br /> gotoxy(iInc,30);<br /> textcolor(7);<br /> cprintf(quot;
|quot;
);<br /> }<br /> gotoxy(30,10);<br /> textcolor(19);<br /> cprintf(quot;
1.ADD quot;
);<br /> gotoxy(30,12);<br /> cprintf(quot;
2.DISPLAYquot;
);<br /> gotoxy(30,14);<br /> cprintf(quot;
3.MODIFYquot;
);<br /> gotoxy(30,16);<br /> cprintf(quot;
4.DELETEquot;
);<br /> gotoxy(30,18);<br /> cprintf(quot;
5.EXITquot;
);<br /> gotoxy(30,20);<br /> textcolor(4);<br /> cprintf(quot;
SELECT YOUR OPTION: quot;
);<br /> fflush(stdin);<br /> cChoice=getche();<br /> clrscr();<br /> gotoxy(25,8);<br /> textcolor(5);<br /> switch(cChoice)<br /> {<br /> case '1':<br /> //To add a record<br /> w:<br /> printf(quot;
ENTER CELL ID( 3 DIGIT NO.): quot;
);<br /> scanf(quot;
%squot;
,cell_id);<br /> rewind(fp);<br /> //Checking for unique id<br /> while(fread(&e,lRecsize,1,fp)==1)<br /> {<br /> if(strcmp(e.cellid,cell_id)==0)<br /> {<br /> iF=1;<br /> printf(quot;
THE ID ALREADY EXISTSquot;
);<br /> goto w;<br /> }}<br /> if(iF==0||fread(&e,lRecsize,1,fp)==0)<br /> {<br /> fseek (fp,0,SEEK_END);<br /> strcpy(e.cellid,cell_id);<br /> a3:<br /> printf(quot;
ENTER ANIMAL NAME: quot;
);<br /> scanf(quot;
%squot;
,e.an_name);<br /> if(strlen(e.an_name)>30||strlen(e.an_name)<3)<br /> goto a3;<br /> printf(quot;
ENTER ZOO KEEPER NAME: quot;
);<br /> scanf(quot;
%squot;
,e.keeper_nm); <br /> p:<br /> printf(quot;
ENTER SEX [M/F]: quot;
);<br /> scanf(quot;
%squot;
,e.an_sex);<br /> if(strlen(e.an_sex)>1)<br /> goto p;<br /> f:<br /> printf(quot;
ENTER AGE : quot;
);<br /> scanf(quot;
%dquot;
,&e.anim_age);<br /> if(e.anim_age<0||e.anim_age>100)<br /> goto f; <br /> a5:<br /> printf(quot;
OFFSPRING [P/A]:quot;
);<br /> scanf(quot;
%squot;
,&e.offspr);<br /> if(strlen(e.offspr)>1)<br /> goto a5;<br /> printf(quot;
ENTER NO. OF OFFSPRING: quot;
);<br /> scanf(quot;
%dquot;
,&e.offno);<br /> printf(quot;
FOOD SUPPLIED( IN KG): quot;
);<br /> scanf(quot;
%fquot;
,&e.food_s);<br /> printf(quot;
FOOD CONSUMED( IN KG): quot;
);<br /> scanf(quot;
%fquot;
,&e.food_c);<br /> a2:<br /> printf(quot;
ANIMAL DETAILS(IF ANY)(Don't leave space,use '_'): quot;
);<br /> scanf(quot;
%squot;
,e.anim_history);<br /> if(strlen(e.anim_history)>50)<br /> goto a2;<br /> fwrite(&e,lRecsize,1,fp);<br /> /*Flushes a stream On success returns 0 , On error returns EOF */<br /> fflush(stdin);<br /> }<br /> break;<br /> case '2':<br /> //Searching and displaying all the infor<br /> // mation by id<br /> textcolor(7);<br /> printf(quot;
ENTER CELL ID: quot;
);<br /> scanf(quot;
%squot;
,cell_id);<br /> rewind(fp);<br /> while(fread(&e,lRecsize,1,fp)!=0)<br /> {<br /> if(strcmp(e.cellid,cell_id)==0)<br /> { iC=1;<br /> clrscr();<br /> //Display according to Main menu<br /> gotoxy(0,20);<br /> //ANIMAL<br /> if(iCh1==1){<br /> printf(quot;
DETAILS OF THE ANIMAL:%squot;
,strupr(e.an_name));<br /> printf(quot;
_____________________________________________________________________quot;
);<br /> printf(quot;
NAME : %s CELL ID : %s ZOO KEEPER NAME : %s SEX: %s AGE : %d OFFSPRING: %s OFFSPRING NO. : %d OFFSPRING RATIO : %f INBREED RATIO : %f FOOD SUPPLIED : %f FOOD CONSUMED : %f ANIMAL DETAILS: %squot;
,strupr(e.an_name),strupr(e.cellid),strupr(e.keeper_nm),strupr(e.an_sex),e.anim_age,strupr(e.offspr),e.offno,(e.offno/13.33*6.2),(e.offno*12.66/17.3574),e.food_s,e.food_c,strupr(e.anim_history));<br /> printf(quot;
_____________________________________________________________________quot;
);<br /> getch(); }<br /> //BIRD<br /> else if(iCh1==2){<br /> printf(quot;
DETAILS OF BIRD:%squot;
,strupr(e.an_name));<br /> printf(quot;
_____________________________________________________________________quot;
);<br /> printf(quot;
NAME : %s CELL ID : %s ZOO KEEPER NAME : %s AGE: %d SEX : %s OFFSPRING: %s OFFSPRING NO. : %d OFFSPRING RATIO : %f INBREED RATIO : %f FOOD SUPPLIED : %f FOOD CONSUMED : %f ANIMAL DETAILS: %squot;
,strupr(e.an_name),strupr(e.cellid),strupr(e.keeper_nm),e.anim_age,strupr(e.an_sex),strupr(e.offspr),e.offno,(e.offno/13.33*6.2),(e.offno*12.66/17.3574),e.food_s,e.food_c,strupr(e.anim_history));<br /> printf(quot;
_____________________________________________________________________quot;
);<br /> getch(); }<br /> }<br /> }<br /> if(iC==0)<br /> {<br /> printf(quot;
RECORD DOESN'T EXISTS..quot;
);<br /> getch();<br /> }iC=0;<br /> break;<br /> case '3':<br /> //Searching and modifying Records by id<br /> cAns='y';<br /> while(cAns=='y')<br /> {<br /> printf(quot;
ENTER CELL ID: quot;
);<br /> scanf(quot;
%squot;
,cell_id);<br /> rewind(fp);<br /> while(fread(&e,lRecsize,1,fp)==1)<br /> {<br /> if(strcmp(e.cellid,cell_id)==0)<br /> {<br /> b:<br /> printf(quot;
ENTER ANIMAL NAME: %s : quot;
,strupr(e.an_name));<br /> scanf(quot;
%squot;
,e.an_name);<br /> if(strlen(e.an_name)>20||strlen(e.an_name)<3)<br /> goto b;<br /> b1:<br /> printf(quot;
ENTER SEX : %s : quot;
,strupr(e.an_sex));<br /> scanf(quot;
%squot;
,e.an_sex);<br /> if(strlen(e.an_sex)>1)<br /> goto b1;<br /> r:<br /> printf(quot;
ENTER AGE: %d : quot;
,e.anim_age);<br /> scanf(quot;
%dquot;
,&e.anim_age);<br /> if(e.anim_age<1||e.anim_age>100)<br /> goto r;<br /> ad:<br /> printf(quot;
OFFSPRING : %s : quot;
,strupr(e.offspr));<br /> scanf(quot;
%squot;
,e.offspr);<br /> if(strlen(e.offspr)<1)<br /> goto ad;<br /> printf(quot;
ENTER NO. OF OFFSPRING: %d :quot;
,e.offno);<br /> scanf(quot;
%dquot;
,&e.offno);<br /> printf(quot;
ENTER FOOD SUPPLIED(IN KG): %f :quot;
,e.food_s);<br /> scanf(quot;
%fquot;
,&e.food_s);<br /> printf(quot;
FOOD CONSUMED( IN KG): quot;
);<br /> scanf(quot;
%fquot;
,&e.food_c);<br /> b5:<br /> printf(quot;
ANIMAL DETAILS( IF ANY )(Dont leave space,use'_'instead)': %s : quot;
,e.anim_history);<br /> scanf(quot;
%squot;
,e.anim_history);<br /> if(strlen(e.anim_history)>50)<br /> goto b5;<br /> fseek(fp,-lRecsize,SEEK_CUR); //Repositions the file pointer of a stream<br /> fwrite(&e,lRecsize,1,fp);<br /> printf(quot;
RECORD MODIFIED quot;
);<br /> break;<br /> }<br /> }<br /> printf(quot;
DO U WANT TO MODIFY ANY RECORD[y/n]quot;
);<br /> /*Flushes a stream On success returns 0 , On error returns EOF */<br /> fflush(stdin);<br /> cAns=getche();<br /> }<br /> break;<br /> case '4':<br /> //Searching and deleting records by id<br /> cAns='y';<br /> while(cAns=='y')<br /> {<br /> printf(quot;
ENTER CELL ID TO DELETE RECORD : quot;
);<br /> scanf(quot;
%squot;
,cell_id);<br /> ft=fopen(quot;
temp.datquot;
,quot;
wbquot;
);<br /> rewind(fp); //Repositions file pointer to stream's beginning<br /> while(fread(&e,lRecsize,1,fp)!=0)<br /> {<br /> if(strcmp(e.cellid,cell_id)!=0) {<br /> fwrite(&e,lRecsize,1,ft);<br /> }<br /> else {<br /> iF1=1;<br /> printf(quot;
RECORD DELETED SUCCESSFULLYquot;
);<br /> }<br /> }<br /> if(iF1!=1){iF1=0;<br /> printf(quot;
NO SUCH RECORD FOUNDquot;
);}<br /> fclose(fp);<br /> fclose(ft);<br /> remove(quot;
zm.datquot;
);<br /> rename(quot;
temp.datquot;
,quot;
zm.datquot;
);<br /> fp=fopen(quot;
zm.datquot;
,quot;
rb+quot;
);<br /> printf(quot;
DO U WANT TO DELETE ANOTHER RECORD[y/n]quot;
);<br /> fflush(stdin);<br /> cAns=getche();<br /> }<br /> break;<br /> case '5':<br /> fclose(fp);<br /> goto e;<br /> }<br /> }<br /> }<br /> }<br />