Sie sind auf Seite 1von 11

CAR INSURANCE 2013

#include<stdio.h>
#include<process.h>
#include<conio.h>
#include<iostream.h>
#include<dos.h>

void entry();
void display();
void search();
void del();
void edit();
void help();
void design();
void box(int,int);
void bbox();

/*void print();*/
//void exit();*/

struct badar
{
char insu_comp[20],accid[20],shop[20];
int model,los;
int engine,charge,total;
};
badar temp;
FILE *ptr;

/***********************MAIN MENU***********************/

void main()
{
textcolor(LIGHTGREEN+BLUE);
char ch;
clrscr();
design();
clrscr();
textcolor(WHITE+DARKGRAY);
gotoxy(4,1);
cprintf("@@@@@@@@@@@@@@@@@@@@@@@@ SWISS INSURANCE COMPANY
@@@@@@@@@@@@@@@@@@@@@@@@@@");
textcolor(BROWN);
gotoxy(27,6);
cprintf("1-New car entry.");
gotoxy(27,8);
cprintf("2-Display car details.");

gotoxy(27,10);
cprintf("3-Search for car record.");

Vaibhav Pandey Page 1


CAR INSURANCE 2013

gotoxy(27,12);
cprintf("4-Delete specific car record.");
gotoxy(27,14);
cprintf("5-Edit specific record.");
gotoxy(27,16);
cprintf("6-Help for users.");
gotoxy(27,18);
cprintf("7-Exit.");
gotoxy(30,20);
textcolor(DARKGRAY);
cprintf("Select an option:");
ch=getche();

switch(ch)

{
case '1':entry();
break;
case '2':display();
break;
case '3':search();
break;
case '4':del();
break;
case '5':edit();
break;
case '6':help();
break;
case '7':exit(0);
break;
default:

gotoxy(40,23);
cprintf("Wrong Entry");
getch();
main();

}
}
//*********************NEW CAR RECORD ENTRY**************************

void entry()
{
char a='y';
clrscr();

ptr=fopen("badar.dat","ab+");

while(a=='y')
{
clrscr();

Vaibhav Pandey Page 2


CAR INSURANCE 2013

gotoxy(28,2);
printf("NEW SURVEY CAR ENTRY");
gotoxy(6,3);
printf("---------------------------------------------------------------------");
gotoxy(2,4);
printf("1)Insurance company name=");
scanf("%s",temp.insu_comp);
gets(temp.insu_comp);
flushall();
gotoxy(2,6);
printf("2)Car model=");
scanf("%d",&temp.model);
flushall();
gotoxy(2,8);
printf("3)Engine number=");
scanf("%d",&temp.engine);
flushall();
gotoxy(2,10);
printf("4)Place of accident=");
scanf("%s",temp.accid);
flushall();
gotoxy(2,12);
printf("5)Repairer shop=");
scanf("%s",temp.shop);
flushall();
gotoxy(2,14);
printf("6)Enter loss of parts=");
scanf("%d",&temp.los);
flushall();
gotoxy(2,16);
printf("7)Enter labour charge=");
scanf("%d",&temp.charge);
temp.total=temp.los*temp.charge;
flushall();
gotoxy(2,18);
printf("8)Total loss=%d\n",temp.total);
fwrite(&temp,sizeof(temp),1,ptr);
gotoxy(29,22);
printf("You want to enter more records(y/n)");
a=getche();
continue;
}
fclose(ptr);
main();
}

/**********************RECORD DISPLAY***********************/

void display()
{ textcolor(BLUE);

Vaibhav Pandey Page 3


CAR INSURANCE 2013

int j;
int r=10;
clrscr();
ptr=fopen("badar.dat","rb");
gotoxy(30,3);
printf("SURVEY CAR ENTRY");
gotoxy(28,4);
printf("\n");
for(j=0;j<80;j++)
printf("-");
gotoxy(6,6);
printf("Company");
gotoxy(6,7);
printf("Name");
gotoxy(20,6);
printf("Car");
gotoxy(20,7);
printf("Model");
gotoxy(30,6);
printf("EngineNo.");
gotoxy(44,6);
printf("Accident");
gotoxy(44,7);
printf("place");
gotoxy(58,6);
printf("Repair");
gotoxy(58,7);
printf("Shop");
gotoxy(70,6);
printf("Total");
gotoxy(70,7);
printf("Loss");
printf("\n");
for(j=0;j<80;j++)
printf("-");
while(fread(&temp,sizeof(temp),1,ptr)==1)
{
gotoxy(6,r);
printf("%s",temp.insu_comp);
flushall();
gotoxy(20,r);
printf("%d",temp.model);
flushall();
gotoxy(30,r);
printf("%d",temp.engine);
flushall();
gotoxy(44,r);
printf("%s",temp.accid);
flushall();
gotoxy(58,r);

Vaibhav Pandey Page 4


CAR INSURANCE 2013

printf("%s",temp.shop);
flushall();
gotoxy(70,r);
printf("%d",temp.total);
flushall();
r++;
}
fclose(ptr);
getch();
main();
}

/***************************SEARCH SPECIFIED RECORD***********************/

void search()
{
char another='y';
ptr=fopen("badar.dat","rb");

while(another=='y')
{
int check=0;
int x;
clrscr();
gotoxy(26,8);
printf("Enter Engine No to View:");
scanf("%d",&x);
gotoxy(26,8);
rewind(ptr);
while(fread(&temp,sizeof(temp),1,ptr)==1)
{
if(temp.engine==x)
{
gotoxy(26,10);
printf(" Company Name is: %s",temp.insu_comp);
gotoxy(26,12);
printf(" Car Model is: %d",temp.model);
gotoxy(26,14);
printf(" Palce of accident is: %s",temp.accid);
gotoxy(26,16);
printf(" Repairer Shop is: %s",temp.shop);
gotoxy(26,18);
printf(" TotalLoss: %d",temp.total);
check=1;
break;
}
}

if(check==0)
{
gotoxy(28,18);

Vaibhav Pandey Page 5


CAR INSURANCE 2013

printf("Car of this EngineNo.Does not Exist");


}
gotoxy(28,20);
printf("View More Records y/n...");
another=getche();
continue;
}
fclose(ptr);
main();
}
/*************************DELETION******************************/

void del()
{
int r,found;
char choice;

FILE *ptr,*tptr;
textbackground(BLACK);
textcolor(RED);
ptr=fopen("badar.dat","rb");
tptr=fopen("badar.tmp","wb");
clrscr();
gotoxy(24,4);
printf("Enter Engine Number to Delete:");
scanf("%d",&r);
found=0;
while(fread(&temp,sizeof(temp),1,ptr)==1)
{
if(temp.engine==r)
{
found=1;
clrscr();
gotoxy(24,6);

printf("\n Insurance company:%s",temp.insu_comp);


gotoxy(24,8);
printf("\n Car model:%d\n",temp.model);
gotoxy(24,10);
printf("\n Place of Accident:%s\n",temp.accid);
gotoxy(24,12);
printf("\n repairer shop:%s\n",temp.shop);
// temp.total=temp.price*temp.quantity;
// printf("\n Total:Rs5%d\n",temp.total);
printf("\n Is this record to be deleted(y/n)");
choice=getche();
if(choice=='n'||choice=='N')
fwrite(&temp,sizeof(temp),1,tptr);
}
else
fwrite(&temp,sizeof(temp),1,tptr);

Vaibhav Pandey Page 6


CAR INSURANCE 2013

}
if(!found)
{
printf("\t\tNo Such 'Engine Number'Exist in the file...\a");
getch();
}
fclose(ptr);
fclose(tptr);
if(found)
{
remove("badar.dat");
rename("badar.tmp","badar.dat");
}
main();
}

/****************************EXIT MODULE****************************/

void exit()
{
textcolor(15);
textbackground(29);
textcolor(13);
clrscr();
gotoxy(26,2);
printf("\aThank you for using this Software.\n");
gotoxy(12,4);
printf("This Software has been especially designed for 'TANWAR&Corp.'.\n");
gotoxy(28,8);
printf("WARNING!!!!");
printf("\n\n Any unathorized use,distribution or duplication of this software is strcitly
prohibited.");
printf("\n\n\n\n\n\t\t***********HAVE A GOOD DAY********************");
getch();
main();
}

/**************************HELP TOPICS*******************************/

void help()

textcolor(GREEN);
clrscr();
printf("\t\t\t\tHELP FOR USERS");
gotoxy(2,3);
printf("This program is very simple and self explanatry.");
printf("\n");
printf("\n1. First run the program by pressing Ctrl+F9.");
printf("\n");

Vaibhav Pandey Page 7


CAR INSURANCE 2013

printf("\n2. A page will open which contains all the actions which can be performed by\n the
program.");
printf("\n");
printf("\n3. If you want to record the data of new survey car,press key 1.");
printf("\n");
printf("\n4. In order to view all the entered records,press key 2.");
printf("\n");
printf("\n5. If you to know the information of a prticular car,press key 3\n and enter car's
engine number.");
printf("\n");
printf("\n6. To get rid of unnecessary records,you may want to delete it,so press key 4\n and
enter car's engine number for that purpose.");
printf("\n");
printf("\n7. If you need a hard copy of entered records or any other page cotained in the
program,press key 6.");
printf("\n");
printf("\n8. When you finish your work,press key 7 to exit.");
getch();
main();

/**************************EDIT RECORD*******************************/

void edit()

{
FILE *tptr;
int found=0;
int id;
char choice;
int tot;
clrscr();
ptr=fopen("badar.dat","rb");
tptr=fopen("badar.tmp","wb");
gotoxy(30,2);
printf("NEW SURVEY CAR ENTRY");
gotoxy(28,3);
printf("--------------------------");
gotoxy(26,6);
printf("Enter engine No to Edit:");
scanf("%d",&id);
gotoxy(26,8);
while(fread(&temp,sizeof(temp),1,ptr)==1)
{
if(temp.engine==id)
{
found=1;
printf("Insurance company name[%s]",temp.insu_comp);
scanf("%s",temp.insu_comp);
gotoxy(26,10);

Vaibhav Pandey Page 8


CAR INSURANCE 2013

printf("Car model[%d]",temp.model);
scanf("%d",&temp.model);
gotoxy(26,12);
printf("Place of accident[%s]",temp.accid);
scanf("%s",temp.accid);
gotoxy(26,14);
printf("Repairer shop[%s]",temp.shop);
scanf("%s",temp.shop);
gotoxy(26,16);
printf("enter loss of parts[%d]",temp.los);
scanf("%d",&temp.los);
gotoxy(26,18);
printf("Enter labour charges[%d]",temp.charge);
scanf("%d",&temp.charge);
temp.total=temp.los*temp.charge;
gotoxy(26,20);
printf("Total Loss%d\n",temp.total);
gotoxy(26,22);
printf("Want to Save it(y/n)...");
choice=getche();
if(choice=='n'||choice=='N')
fwrite(&temp,sizeof(temp),1,tptr);
else
fwrite(&temp,sizeof(temp),1,tptr);
}
}
if(!found)
{
printf("No such number exist in the file...\a");
getch();
}
fclose(ptr);
fclose(tptr);
if(found)
{
remove("badar.dat");
rename("badar.tmp","badar.dat");
}
main();
}

/***************************DESIGNING*****************************/

void design()
{
int l=17;
int l1=4;
box(l,l1);
bbox();
gotoxy(27,5);

Vaibhav Pandey Page 9


CAR INSURANCE 2013

delay(330);
textcolor(GREEN);
cprintf("I N T R O D U C T I O N");
textcolor(LIGHTCYAN+DARKGRAY);
delay(345);
gotoxy(25,8);
cprintf("The project of Computerization");
gotoxy(37,10);
delay(355);
cprintf("FOR");
gotoxy(29,12);
delay(365);
cprintf("SWISS INSURANCE COMPANY");
gotoxy(33,13);
delay(375);
cprintf("Insurance Surveyor");
gotoxy(32,14);
delay(385);
cprintf("Loss Accessor");
gotoxy(34,15);
delay(395);
cprintf("DELHI");
gotoxy(50,18);
delay(410);
cprintf("Prepared By...");
gotoxy(57,20);
delay(420);
cprintf("VAIBHAV PANDEY");
gotoxy(45,23);
textcolor(RED);
delay(425);
cprintf("***PRESS ANY KEY TO CONTINUE***");
getch();
}
void box(int l,int l1)
{
int c,r;
gotoxy(22,l1);
cout<<"<<";
for(c=24;c<=55;c++)
{
gotoxy(c,l1);//l1=2
cout<<"l";
gotoxy(c,l1+2);//l1+2
cout<<"l";
gotoxy(c,l);
cout<<"l";
}
gotoxy(56,l1);//l1
cout<<">>";

Vaibhav Pandey Page 10


CAR INSURANCE 2013

gotoxy(23,l1+1);//l1+1
cout<<"*";
gotoxy(56,l1+1);//l1+1
cout<<"*";
gotoxy(23,l1+2);//l1+22
cout<<"l";
gotoxy(56,l1+2);//l1+2
cout<<"l";
for(r=l1+3;r<=l;r++)//r=;l1+3

gotoxy(23,r);
cout<<"";
gotoxy(56,r);
cout<<"<-";
}
gotoxy(23,l);
cout<<"l";
gotoxy(56,l);
cout<<"l";
}
void bbox()
{
int c,r;
for(c=1;c<=79;c++)
{
textcolor(BLUE);
gotoxy(c,1);
cprintf("

");
gotoxy(c,25);
cprintf("

");
}
for(r=1;r<=24;r++)
{
gotoxy(1,r);
cprintf("

");
gotoxy(79,r);
cprintf("

");
}
}

Vaibhav Pandey Page 11

Das könnte Ihnen auch gefallen