wildlife conservation project management adri jovin

10
#include<iostream.h> #include<stdio.h> #include<conio.h> #include<dos.h> #include<string.h> void main() { int iCh1,iInc; e: clrscr(); /* To Display Main menu */ gotoxy(26,40); textcolor(9); cprintf("SOFTWARE ENGINEERING PROJECT"); gotoxy(32,44); textcolor(19); cprintf("BATCH-1(2006-07)"); gotoxy(23,42); cprintf("WILDLIFE CONSERVATION MANAGEMENT SYSTEM ( WLCPM- 2007)"); gotoxy(8,45); textcolor(9); /* To Display date and time */ cprintf("DATE : %s ",__DATE__); gotoxy(55,45); cprintf("TIME : %s ",__TIME__); for(iInc=0;iInc<=30;iInc++) { gotoxy(20,iInc); textcolor(7); cprintf("-"); } for(iInc=0;iInc<80;iInc++) { gotoxy(iInc,30); textcolor(7); cprintf("|"); } gotoxy(30,8); textcolor(9); /* Main menu */

Upload: adri-jovin

Post on 27-Jan-2015

109 views

Category:

Education


5 download

DESCRIPTION

This was my Software Engineering Mini-project while I was doing my UG in St.Xavier's Catholic College of Engineering

TRANSCRIPT

Page 1: Wildlife conservation project management  adri jovin

#include<iostream.h> #include<stdio.h> #include<conio.h> #include<dos.h> #include<string.h> void main() { int iCh1,iInc; e: clrscr(); /* To Display Main menu */ gotoxy(26,40); textcolor(9); cprintf("SOFTWARE ENGINEERING PROJECT"); gotoxy(32,44); textcolor(19); cprintf("BATCH-1(2006-07)"); gotoxy(23,42); cprintf("WILDLIFE CONSERVATION MANAGEMENT SYSTEM ( WLCPM-2007)"); gotoxy(8,45); textcolor(9); /* To Display date and time */ cprintf("DATE : %s ",__DATE__); gotoxy(55,45); cprintf("TIME : %s ",__TIME__); for(iInc=0;iInc<=30;iInc++) { gotoxy(20,iInc); textcolor(7); cprintf("-"); } for(iInc=0;iInc<80;iInc++) { gotoxy(iInc,30); textcolor(7); cprintf("|"); } gotoxy(30,8); textcolor(9); /* Main menu */ cprintf("WILDLIFE CONSERVATION MANAGEMENT SYSTEM (WLCPM-2007)"); gotoxy(30,10); textcolor(19); cprintf("1.FOREST CONSERVATION"); gotoxy(30,12); cprintf("2.DESERT CONSERVATION"); gotoxy(30,14); cprintf("3.EXIT"); gotoxy(30,18); textcolor(9);

Page 2: Wildlife conservation project management  adri jovin

cprintf("ENTER YOUR CHOICE:"); scanf("%d",&iCh1); if (iCh1==3) { /* To exit from the system */ gotoxy(30,28); textcolor(4); cprintf("SYSTEM SHUTTING DOWN"); sleep(3); gotoxy(26,40); printf("SOFTWARE ENGINEERING PROJECT"); gotoxy(8,42); printf("WILDLIFE CONSERVATION MANAGEMENT SYSTEM ( WLCPM-2007)"); gotoxy(8,45); printf("DATE : %s ",__DATE__); gotoxy(55,45); printf("TIME : %s ",__TIME__); //exit(0); } else{ /* Declarations of Variables */ FILE *fp,*ft; char cAns,cChoice; struct zoo { char offspr[2],anim_history[50],an_name[30],keeper_nm[20],cellid[4],an_sex[2]; int anim_age,offno; float wt,offrat,inbreed,food_s,food_c; }; struct zoo e; char cell_id[4]; int iF=0,iC=0,iF1=0; long int lRecsize; fp=fopen("zm.dat","rb+"); if(fp==NULL) { fp=fopen("\zm.dat","wb+"); if(fp==NULL) { puts("\n\t\tCannot Open file"); //exit(); } } lRecsize=sizeof(e); while(1) { clrscr(); textcolor(4); if(iCh1==1) {

Page 3: Wildlife conservation project management  adri jovin

gotoxy(30,8); textcolor(4); cprintf("ANIMAL MENU"); } else if(iCh1==2) { gotoxy(30,8); textcolor(4); cprintf("BIRD MENU"); } gotoxy(26,40); textcolor(4); cprintf("SOFTWARE ENGINEERING PROJECT"); gotoxy(32,44); textcolor(19); cprintf("BATCH-1(2006-07)"); gotoxy(23,42); textcolor(19); cprintf("WILDLIFE CONSERVATION MANAGEMENT SYSTEM ( WLCPM-2007 )"); gotoxy(8,45); textcolor(4); cprintf("DATE : %s ",__DATE__); gotoxy(55,45); cprintf("TIME : %s ",__TIME__); for(iInc=0;iInc<=30;iInc++) { gotoxy(20,iInc); textcolor(7); cprintf("-"); } for(iInc=0;iInc<=80;iInc++) { gotoxy(iInc,30); textcolor(7); cprintf("|"); } gotoxy(30,10); textcolor(19); cprintf("1.ADD "); gotoxy(30,12); cprintf("2.DISPLAY"); gotoxy(30,14); cprintf("3.MODIFY"); gotoxy(30,16); cprintf("4.DELETE"); gotoxy(30,18); cprintf("5.EXIT"); gotoxy(30,20); textcolor(4); cprintf("SELECT YOUR OPTION: "); fflush(stdin); cChoice=getche(); clrscr();

Page 4: Wildlife conservation project management  adri jovin

gotoxy(25,8); textcolor(5); switch(cChoice) { case '1': //To add a record w: printf("\n\n\n\t\tENTER CELL ID( 3 DIGIT NO.): "); scanf("%s",cell_id); rewind(fp); //Checking for unique id while(fread(&e,lRecsize,1,fp)==1) { if(strcmp(e.cellid,cell_id)==0) { iF=1; printf("\n\t\tTHE ID ALREADY EXISTS"); goto w; }} if(iF==0||fread(&e,lRecsize,1,fp)==0) { fseek (fp,0,SEEK_END); strcpy(e.cellid,cell_id); a3: printf("\n\t\tENTER ANIMAL NAME: "); scanf("%s",e.an_name); if(strlen(e.an_name)>30||strlen(e.an_name)<3) goto a3; printf("\n\t\tENTER ZOO KEEPER NAME: "); scanf("%s",e.keeper_nm); p: printf("\n\t\tENTER SEX [M/F]: "); scanf("%s",e.an_sex); if(strlen(e.an_sex)>1) goto p; f: printf("\n\t\tENTER AGE : "); scanf("%d",&e.anim_age); if(e.anim_age<0||e.anim_age>100) goto f; a5: printf("\n\t\tOFFSPRING [P/A]:"); scanf("%s",&e.offspr); if(strlen(e.offspr)>1) goto a5; printf("\n\t\tENTER NO. OF OFFSPRING: "); scanf("%d",&e.offno); printf("\n\t\tFOOD SUPPLIED( IN KG): "); scanf("%f",&e.food_s); printf("\n\t\tFOOD CONSUMED( IN KG): ");

Page 5: Wildlife conservation project management  adri jovin

scanf("%f",&e.food_c); a2: printf("\n\t\tANIMAL DETAILS(IF ANY)\n\t\t(Don't leave space,use '_'): "); scanf("%s",e.anim_history); if(strlen(e.anim_history)>50) goto a2; fwrite(&e,lRecsize,1,fp); /*Flushes a stream On success returns 0 , On error returns EOF */ fflush(stdin); } break; case '2': //Searching and displaying all the infor // mation by id textcolor(7); printf("\n\n\n\t\tENTER CELL ID: "); scanf("%s",cell_id); rewind(fp); while(fread(&e,lRecsize,1,fp)!=0) { if(strcmp(e.cellid,cell_id)==0) { iC=1; clrscr(); //Display according to Main menu gotoxy(0,20); //FOREST CONSERVATION if(iCh1==1){ printf("\n\n\n\t\tDETAILS OF THE ANIMAL:%s",strupr(e.an_name)); printf("\n_____________________________________________________________________\n\n"); printf("\n\n NAME : %s\t CELL ID : %s\t ZOO KEEPER NAME : %s\n\n SEX: %s\t AGE : %d \n\n OFFSPRING: %s\n\n OFFSPRING NO. : %d\n\n OFFSPRING RATIO : %f\n\n INBREED RATIO : %f\n\n FOOD SUPPLIED : %f\n\n FOOD CONSUMED : %f\n\n ANIMAL DETAILS: %s",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)); printf("\n_____________________________________________________________________\n\n"); getch(); } //DESERT CONSERVATION else if(iCh1==2){ printf("\n\n\n\t\tDETAILS OF BIRD:%s",strupr(e.an_name)); printf("\n_____________________________________________________________________\n\n"); printf("\n\n NAME : %s\t CELL ID : %s\t ZOO KEEPER NAME : %s\n\n AGE: %d\t SEX : %s \t OFFSPRING: %s\n\n OFFSPRING NO. : %d\n\n OFFSPRING RATIO : %f\n\n INBREED RATIO : %f\n\n FOOD SUPPLIED : %f\n\n FOOD CONSUMED : %f\n\n ANIMAL DETAILS: %s",strupr(e.an_name),strupr(e.cellid),strupr(e.keeper_nm),e.anim_age,strupr(e.an_sex),strup

Page 6: Wildlife conservation project management  adri jovin

r(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)); printf("\n_____________________________________________________________________\n\n"); getch(); } } } if(iC==0) { printf("\n\t\tRECORD DOESN'T EXISTS.."); getch(); }iC=0; break; case '3': //Searching and modifying Records by id cAns='y'; while(cAns=='y') { printf("\n\n\n\t\tENTER CELL ID: "); scanf("%s",cell_id); rewind(fp); while(fread(&e,lRecsize,1,fp)==1) { if(strcmp(e.cellid,cell_id)==0) { b: printf("\n\n\t\tENTER ANIMAL NAME: %s : ",strupr(e.an_name)); scanf("%s",e.an_name); if(strlen(e.an_name)>20||strlen(e.an_name)<3) goto b; b1: printf(" \n\t\tENTER SEX : %s : ",strupr(e.an_sex)); scanf("%s",e.an_sex); if(strlen(e.an_sex)>1) goto b1; r: printf(" \n\t\tENTER AGE: %d : " ,e.anim_age); scanf("%d",&e.anim_age); if(e.anim_age<1||e.anim_age>100) goto r; ad: printf(" \n\t\tOFFSPRING : %s : ",strupr(e.offspr)); scanf("%s",e.offspr); if(strlen(e.offspr)<1) goto ad; printf(" \n\t\tENTER NO. OF OFFSPRING: %d :",e.offno); scanf("%d",&e.offno); printf(" \n\t\tENTER FOOD SUPPLIED(IN KG): %f :",e.food_s); scanf("%f",&e.food_s); printf("\n\t\tFOOD CONSUMED( IN KG): ");

Page 7: Wildlife conservation project management  adri jovin

scanf("%f",&e.food_c); b5: printf("\n\t\tANIMAL DETAILS( IF ANY )\n\t\t(Dont leave space,use'_'instead)': %s : ",e.anim_history); scanf("%s",e.anim_history); if(strlen(e.anim_history)>50) goto b5; fseek(fp,-lRecsize,SEEK_CUR); //Repositions the file pointer of a stream fwrite(&e,lRecsize,1,fp); printf("\n\t\tRECORD MODIFIED "); break; } } printf("\n\n\n\t\tDO U WANT TO MODIFY ANY RECORD[y/n]"); /*Flushes a stream On success returns 0 , On error returns EOF */ fflush(stdin); cAns=getche(); } break; case '4': //Searching and deleting records by id cAns='y'; while(cAns=='y') { printf("\n\n\t\tENTER CELL ID TO DELETE RECORD : "); scanf("%s",cell_id); ft=fopen("temp.dat","wb"); rewind(fp); //Repositions file pointer to stream's beginning while(fread(&e,lRecsize,1,fp)!=0) { if(strcmp(e.cellid,cell_id)!=0) { fwrite(&e,lRecsize,1,ft); } else { iF1=1; printf("\n\n\t\t RECORD DELETED SUCCESSFULLY"); } } if(iF1!=1){iF1=0; printf("\n\n\t\t NO SUCH RECORD FOUND");} fclose(fp); fclose(ft); remove("zm.dat"); rename("temp.dat","zm.dat"); fp=fopen("zm.dat","rb+"); printf("\n\n\t\tDO U WANT TO DELETE ANOTHER RECORD[y/n]"); fflush(stdin); cAns=getche(); } break;

Page 8: Wildlife conservation project management  adri jovin

case '5': fclose(fp); goto e; } } } }