Académique Documents
Professionnel Documents
Culture Documents
h>
#include<stdlib.h>
#include <string.h>
#define size 20
struct hotel
int roomNum;
char firstName[size];
char lastName[size];
char roomType[size];
char paymentType[2];
int numberOfNights;
int age;
float amount;
};
int findGross(char type[],int nights)
float gross;
if (strcmp( type,"single")==0)
gross=nights*single;
else
if (strcmp( type,"singlesea")==0)
gross=nights*singlesea;
else
if (strcmp( type,"double")==0)
gross=nights*duble;
else
if (strcmp( type,"doubledsea")==0)
gross=nights*doublesea;
else
if (strcmp( type,"suite")==0)
{
gross=nights*suite;
else
if (strcmp( type,"suitesea")==0)
gross=nights*suitesea;
else
if (strcmp( type,"penthouse")==0)
gross=nights*penthouse;
else
if (strcmp( type,"penthousesea")==0)
gross=nights*penthousesea;
return gross;
{
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>::>");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@ ::");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@ ::");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>::>:::>\n\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
int result;
result=num-1;
return result;
}
int choice;
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>");
printf("\n :: :: ::");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :: :: @ @ ::");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :: :: ::");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>\n\n");
scanf("%d",&choice);
return choice;
}/*End Function*/
main()
FILE*pointer;
int roomNum;
char firstName[size];
char lastName[size];
char paymentType[2];
char roomType[size];
int age[5];
int numberOfNights;
float amount,bill;
int choice4,temproomnumber4,tempage4,tempnights4;
char tempfname4[size];
char templname4[size];
char temproomtype[size];
char ch;
int identification,result,f,temp;
s=10;
ss=10;
d=10;
ds=10;
s2=10;
ss2=10;
p=10;
ps=10;
while(result!=7)
if(result==1)
if((pointer=fopen("guestitinerary","wb"))==NULL)
exit(1);
}/*end if*/
else
for (f=0;f<=100;f++)
{
fwrite(&guest,sizeof(struct hotel),1,pointer);
} /*end for*/
fclose(pointer);
printf("\n :: >::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>::>");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>\n");
}/*end if*/
if(result==2)
printf("\n -------------------\n");
if((pointer=fopen("guestitinerary","rb+"))==NULL)
exit(1);
scanf("%d",&guest.roomNum);
scanf("%s",&guest.firstName);
scanf("%s",&guest.lastName);
scanf("%s",&guest.roomType);
scanf("%s",&guest.paymentType);
printf("enter the number of nights staying\n");
scanf("%d",&guest.numberOfNights);
scanf("%d",&guest.age);
guest.amount=findGross(guest.roomType,guest.numberOfNights);
fseek(pointer,(guest.roomNum-1)*sizeof(struct hotel),SEEK_SET);
fwrite(&guest,sizeof(struct hotel),1,pointer);
fclose(pointer);
if (strcmp(guest.roomType ,"single")==0)
s=subtract(s);
else
if (strcmp( guest.roomType,"singlesea")==0)
ss=subtract(ss);
else
if (strcmp( guest.roomType,"double")==0)
d=subtract(d);
else
if (strcmp( guest.roomType,"doubledsea")==0)
{
ds=subtract(ds);
else
if (strcmp( guest.roomType,"suite")==0)
s2=subtract(s2);
else
if (strcmp( guest.roomType,"suitesea")==0)
ss2=subtract(ss2);
else
if (strcmp( guest.roomType,"penthouse")==0)
p=subtract(p);
else
if (strcmp( guest.roomType,"penthousesea")==0)
ps=subtract(ps);
}
result=MenuChoice();/*call to function MenuChoice*/
}//END IF
printf("ERROR\n");
else
printf("\n :: >::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>::>");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>\n");
while(!feof(pointer))
fread(&guest,sizeof(struct hotel),1,pointer);
if(guest.roomNum!=0)
printResults(guest.roomNum,guest.firstName,guest.lastName,guest.roomType,guest.paymentType,gues
t.numberOfNights,guest.age,guest.amount);
printf("\n\n\n");
printf("\n\n");
printf("============================================================\n\n ");
}//END IF
}/*end while*/
}/*end else*/
fclose(pointer);
} /*end if*/
if(result==4)
exit(1);
}/*end if*/
else{
scanf("%d",&temproomnumber4);
fseek(pointer,(temproomnumber4-1)*sizeof(struct hotel),SEEK_SET);
fread(&guest,sizeof(struct hotel),1,pointer);
/*Read Mode*/
if(guest.roomNum==0)
printf("\n :: >::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>::>");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>\n");
}/*end if*/
if(guest.roomNum!=0)
{
printResults(guest.roomNum,guest.firstName,guest.lastName,guest.roomType,guest.paymentType,gues
t.numberOfNights,guest.age,guest.amount);
printf("\n\n");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>");
printf("\n :: ::");
printf("\n ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ::");
printf("\n ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ::");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>\n\n");
printf("enter a request\n");
scanf("%d",&choice4);
while(choice4!=7)
if(choice4==1)
{
printf("Enter the correct first name\n");
scanf("%s",&tempfname4);
printResults(guest.roomNum,guest.firstName,guest.lastName,guest.roomType,guest.paymentType,gues
t.numberOfNights,guest.age,guest.amount);
printf("\n\n");
fseek(pointer,(guest.roomNum-1)*sizeof(struct hotel),SEEK_SET);
fwrite(&guest,sizeof(struct hotel),1,pointer);
fclose(pointer);
} /*end if*/
if(choice4==2)
scanf("%s",&templname4);
printf("\n\n");
fseek(pointer,(guest.roomNum-1)*sizeof(struct hotel),SEEK_SET);
fwrite(&guest,sizeof(struct hotel),1,pointer);
fclose(pointer);
} /*end if*/
if(choice4==3)
scanf("%s",&temproomtype);
printResults(guest.roomNum,guest.firstName,guest.lastName,guest.roomType,guest.paymentType,gues
t.numberOfNights,guest.age,guest.amount);
printf("\n\n");
fseek(pointer,(guest.roomNum-1)*sizeof(struct hotel),SEEK_SET);
fwrite(&guest,sizeof(struct hotel),1,pointer);
fclose(pointer);
} /*end if*/
if(choice4==4)
scanf("%f",&bill);
printResults(guest.roomNum,guest.firstName,guest.lastName,guest.roomType,guest.paymentType,gues
t.numberOfNights,guest.age,guest.amount);
printf("\n\n");
fseek(pointer,(guest.roomNum-1)*sizeof(struct hotel),SEEK_SET);
fwrite(&guest,sizeof(struct hotel),1,pointer);
fclose(pointer);
} /*end if*/
if(choice4==5)
scanf("%d",&tempage4);
guest.age=tempage4;/*editting guests ages*/
printResults(guest.roomNum,guest.firstName,guest.lastName,guest.roomType,guest.paymentType,gues
t.numberOfNights,guest.age,guest.amount);
printf("\n\n");
fseek(pointer,(guest.roomNum-1)*sizeof(struct hotel),SEEK_SET);
fwrite(&guest,sizeof(struct hotel),1,pointer);
fclose(pointer);
} /*end if*/
if(choice4==6)
scanf("%d",&tempnights4);
printResults(guest.roomNum,guest.firstName,guest.lastName,guest.roomType,guest.paymentType,gues
t.numberOfNights,guest.age,guest.amount);
printf("\n\n");
fseek(pointer,(guest.roomNum-1)*sizeof(struct hotel),SEEK_SET);
fwrite(&guest,sizeof(struct hotel),1,pointer);
fclose(pointer);
} /*end if*/
} /*end while*/
} /*end if*/
} /*end else*/
}/*end if*/
if(result==5)
}/*end if*/
printf("\n :: >::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>::>");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>\n");
scanf("%d",&guest.roomNum);
fseek(pointer,(guest.roomNum-1)*sizeof(struct hotel),SEEK_SET);
fread(&guest,sizeof(struct hotel),1,pointer);
/*Read Mode*/
if(guest.roomNum==0)
printf("\n :: >::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>::>");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>\n");
}/*end if*/
if(guest.roomNum!=0)
fseek(pointer,(guest.roomNum-1)*sizeof(struct hotel),SEEK_SET);
fwrite(&blankguest,sizeof(struct hotel),1,pointer);
printf("\n :: >::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>::>");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>\n");
fclose(pointer);
}//END IF
{
struct hotel guest={0,"","","",0,0,0.0};
exit(1);
}/*end if*/
printf("\n :: >::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>::>");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>\n");
scanf("%d",&guest.roomNum);
fseek(pointer,(guest.roomNum-1)*sizeof(struct hotel),SEEK_SET);
fread(&guest,sizeof(struct hotel),1,pointer);
/*Read Mode*/
if(guest.roomNum==0)
{
printf("\n :: >::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>::>");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>\n");
}/*end if*/
if(guest.roomNum!=0)
fseek(pointer,(guest.roomNum-1)*sizeof(struct hotel),SEEK_SET);
printResults(guest.roomNum,guest.firstName,guest.lastName,guest.roomType,guest.paymentType,gues
t.numberOfNights,guest.age,guest.amount);
printf("\n :: >::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>::>");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :: ::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
::");
printf("\n :::>::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>:::>\n");
}
fclose(pointer);
}/*end if*/
} //END WHILE
} //main close