Home » » Hotel Management in C Programming

Hotel Management in C Programming

Welcome to Home Land Hotel
Download Here
and the following code :
=======================================
  1. include
  2. #include
  3. #include
  4. #include
  5. typedef struct {int day;
  6. int month;
  7. int year;
  8. }date;
  9. struct customer{int id;
  10. char name[20];
  11. date da_in;
  12. date da_out;
  13. int n_of_room;
  14. char room;
  15. int price;
  16. }cust[30],temp;
  17. int n,i,j,ID=0; int d,p,e; char a,b,c; int room;
  18. void check_in();
  19. void check_out();
  20. void edit();
  21. void view();
  22. void search();
  23. void draw();
  24. void main()
  25. {
  26. char ch;
  27. while(1)
  28. {clrscr();
  29. textcolor(6); gotoxy(30,2); cprintf("Welcome to Home Land Hotel");textcolor(7);cprintf("");
  30. gotoxy(35,5); printf("Main Menu");
  31. gotoxy(3,9); printf("Please Press Any Keys Below");
  32. gotoxy(8,12); printf("1/ Check In the Customer");
  33. gotoxy(8,14); printf("2/ Check Out the Customer");
  34. gotoxy(8,16); printf("3/ Edit the Customer");
  35. gotoxy(8,18); printf("4/ View List of Customer");
  36. gotoxy(8,20); printf("5/ Search the Customer");
  37. gotoxy(8,22); printf("6/ Exit The Program");
  38. ch=getch();
  39. switch(ch)
  40. {case'1':clrscr(); check_in(); break;
  41. case'2':clrscr(); check_out(); break;
  42. case'3':clrscr(); edit(); break;
  43. case'4':clrscr(); view(); break;
  44. case'5':clrscr(); search(); break;
  45. case'6':clrscr(); exit(1); break;
  46. default:gotoxy(3,27); printf("Error Enter Again!!");getch(); break;
  47. }
  48. }
  49. }
  50.  
  51.  
  52. //********The Function of Program Check in********
  53. void check_in()
  54. {
  55. draw();
  56. gotoxy(30,3); printf("Customer %04d",ID+1);
  57. gotoxy(10,6); printf("Name="); fflush(stdin); gets(cust[ID].name);
  58. gotoxy(10,8); printf("Input Date Check In="); scanf("%d%c%d%c%d",&cust[ID].da_in.day,&a,&cust[ID].da_in.month,&b,&cust[ID].da_in.year);
  59. again:
  60. gotoxy(10,10); printf(" ");
  61. gotoxy(10,10);printf("Room Number="); scanf("%d",&cust[ID].n_of_room);
  62. if( cust[ID].n_of_room109 && cust[ID].n_of_room209 && cust[ID].n_of_room309)
  63. { gotoxy(10,10); printf("NO that Room!!!");
  64. getch(); goto again;}
  65. for(i=0;i<ID;i++)
  66. {if(cust[i].n_of_room==cust[ID].n_of_room)
  67. {gotoxy(10,10); printf("Room Number %d Aready Exist",cust[ID].n_of_room);
  68. getch(); goto again;
  69. }
  70. }
  71. again1:
  72. gotoxy(10,12); printf(" ");
  73. gotoxy(10,12); printf("Type of Room="); fflush(stdin); scanf("%c",&cust[ID].room);
  74. if(cust[ID].room!='D' && cust[ID].room!='d' && cust[ID].room!='S' && cust[ID].room!='s')
  75. {gotoxy(10,12); printf("Error type of room must be D or S ");getch();
  76. goto again1;}
  77.  
  78. cust[ID].id=ID+1;
  79. if(cust[ID].room=='D' || cust[ID].room=='d')
  80. cust[ID].price=20;
  81. if(cust[ID].room=='S' || cust[ID].room=='s')
  82. {cust[ID].price=15;}
  83. cust[ID].da_out.day=0;
  84. cust[ID].da_out.month=0;
  85. cust[ID].da_out.year=0;
  86. ID++;
  87. }
  88. //******The Function of Program Check out********
  89. void check_out()
  90. {
  91. char ch;
  92. gotoxy(10,3); printf ("For Check_out!!! Input Customer ID=");
  93. scanf("%d",&n);
  94. gotoxy(10,6); printf("customer Name=%s Y/N?",cust[n-1].name);ch=getch(); if (ch=='n' || ch== 'N') goto exit;
  95. gotoxy(10,8); printf("Date Check in=%02d/%02d/%02d",cust[n-1].da_in.day,cust[n-1].da_in.month,cust[n-1].da_in.year);
  96. gotoxy(10,10); printf("Input Date Check Out="); scanf("%d%c%d%c%d",&cust[n-1].da_out.day,&a,&cust[n-1].da_out.month,&b,&cust[n-1].da_out.year);
  97. gotoxy(10,12); printf("Room Type = '%c' so the price per night= %02d.00$",cust[n-1].room,cust[n-1].price);
  98. gotoxy(30,18); printf("Thank You");
  99. d=cust[n-1].da_out.day-cust[n-1].da_in.day;
  100. p=d*cust[n-1].price;
  101. gotoxy(25,20); printf("You have Stay for %d days",d);
  102. gotoxy(30,22); printf("Cost=%d.00$",p); getch();
  103. cust[n-1].room=NULL;
  104. cust[n-1].n_of_room=NULL;
  105. cust[n-1].price=NULL;
  106. exit:
  107.  
  108. }
  109. //******The Function of Program View********
  110. void view()
  111. {
  112. clrscr();
  113. gotoxy(30,3); printf("List of Customer");
  114. gotoxy(1,7); printf("ID");
  115. gotoxy(8,7); printf("Name");
  116. gotoxy(24,7); printf("Check_in");
  117. gotoxy(39,7); printf("Check_out");
  118. gotoxy(54,7); printf("NO_of_Room");
  119. gotoxy(67,7); printf("room");
  120. gotoxy(74,7); printf("Price");
  121. gotoxy(1,9); printf("==============================================================================");
  122. for(i=0;i<ID;i++)
  123. {
  124. gotoxy(1,11+(i*2)); printf("%03d",cust[i].id);
  125. gotoxy(8,11+(i*2)); printf("%s",cust[i].name);
  126. gotoxy(23,11+(i*2)); printf("%02d/%02d/%04d",cust[i].da_in.day,cust[i].da_in.month,cust[i].da_in.year);
  127. gotoxy(38,11+(i*2)); printf("%02d/%02d/%04d",cust[i].da_out.day,cust[i].da_out.month,cust[i].da_out.year);
  128. gotoxy(57,11+(i*2)); printf("%d",cust[i].n_of_room);
  129. gotoxy(69,11+(i*2)); printf("%c",cust[i].room);
  130. gotoxy(73,11+(i*2)); printf("%d.00$",cust[i].price);
  131. }
  132. gotoxy(1,11+(i*2)); printf("==============================================================================");
  133. getch();
  134. }
  135.  
  136. //******The Function of Program Edit ********
  137. void edit()
  138. {
  139. gotoxy(20,5); printf("For Editing!!! Input Customer ID="); scanf("%d",&e); clrscr();
  140. draw();
  141. gotoxy(30,3); printf("Customer %04d",e);
  142. gotoxy(10,6); printf("Name=%s -> ",cust[e-1].name); fflush(stdin); gets(cust[e-1].name);
  143. gotoxy(10,8); printf("Input Date Check In=%d/%d/%d -> ",cust[e-1].da_in.day,cust[e-1].da_in.month,cust[e-1].da_in.year);
  144. scanf("%d%c%d%c%d",&cust[e-1].da_in.day,&a,&cust[e-1].da_in.month,&b,&cust[e-1].da_in.year);
  145. again:
  146. gotoxy(10,10); printf(" ");
  147. gotoxy(10,10);printf("Room Number=%d -> ",cust[e-1].n_of_room); scanf("%d",&room);
  148. if( room109 && room209 && room309)
  149. { gotoxy(10,10); printf("NO that Room!!!");
  150. getch(); goto again; }
  151. for(i=0;i<ID;i++)
  152. {if(cust[i].n_of_room==room && room!=cust[e-1].n_of_room)
  153. {gotoxy(10,10); printf("Room Number %d Aready Exist",room);
  154. getch(); goto again;
  155. }
  156. }
  157. again1:
  158. gotoxy(10,12); printf(" ");
  159. gotoxy(10,12); printf("Type of Room=%c -> ",cust[e-1].room); fflush(stdin); scanf("%c",&cust[e-1].room);
  160. if(cust[e-1].room!='D' && cust[e-1].room!='d' && cust[e-1].room!='S' && cust[e-1].room!='s')
  161. {gotoxy(10,12); printf("Error type of room must be D or S ");getch();
  162. goto again1;}
  163.  
  164. cust[e-1].id=e;
  165. if(cust[e-1].room=='D' || cust[e-1].room=='d')
  166. cust[e-1].price=20;
  167. if(cust[e-1].room=='S' || cust[e-1].room=='s')
  168. {cust[e-1].price=15;}
  169. cust[e-1].n_of_room=room;
  170. cust[e-1].da_out.day=0;
  171. cust[e-1].da_out.month=0;
  172. cust[e-1].da_out.year=0;
  173.  
  174. }
  175.  
  176. //******The Function of Program Draw table ********
  177. void draw()
  178. {
  179.  
  180. gotoxy(8,27);printf("ÉÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍ»");
  181. gotoxy(8,28);printf("º º º º º º º º º º");
  182. gotoxy(8,29);printf("º º º º º º º º º º <- floor="" span="" third="">);
  183. gotoxy(8,30);printf("º º º º º º º º º º");
  184. gotoxy(8,31);printf("ÌÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍ͹");
  185. gotoxy(8,32);printf("º º º º º º º º º º");
  186. gotoxy(8,33);printf("º º º º º º º º º º <- floor="" second="" span="">);
  187. gotoxy(8,34);printf("º º º º º º º º º º");
  188. gotoxy(8,35);printf("ÌÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍ͹");
  189. gotoxy(8,36);printf("º º º º º º º º º º");
  190. gotoxy(8,37);printf("º º º º º º º º º º <- first="" floor="" span="">);
  191. gotoxy(8,38);printf("º º º º º º º º º º");
  192. gotoxy(8,39);printf("ÈÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍͼ");
  193. for(i=0;i<9;i++)
  194. {
  195. gotoxy(10+(6*i),29);
  196. for(j=0;j<ID;j++)
  197. {
  198. if(cust[j].n_of_room==301+i)
  199. {
  200. textcolor(RED);
  201. }
  202. }
  203. cprintf("%d",301+i); textcolor(WHITE);
  204. gotoxy(10+(6*i),33);
  205. for(j=0;j<ID;j++)
  206. {
  207. if(cust[j].n_of_room==201+i)
  208. {
  209. textcolor(RED);
  210. }
  211. }
  212. cprintf("%d",201+i); textcolor(WHITE);
  213. gotoxy(10+(6*i),37);
  214. for(j=0;j<ID;j++)
  215. {
  216. if(cust[j].n_of_room==101+i)
  217. {
  218. textcolor(RED);
  219. }
  220. }
  221. cprintf("%d",101+i); textcolor(WHITE);
  222. }
  223. }
  224. //******The Function of Program Search ********
  225. void search()
  226. {
  227. again:
  228. clrscr();
  229. int f=0; int d,m,y; char sn[20]; int si, room;
  230. gotoxy(30,3); printf("Search List of Customer");
  231. gotoxy(3,10); printf(">>Please Press Any Keys Below");
  232. gotoxy(8,12); printf("1/Search by ID");
  233. gotoxy(8,14); printf("2/Search by Date(Check In)");
  234. gotoxy(8,16); printf("3/Search by Date(Chck Out)");
  235. gotoxy(8,18); printf("4/Search by Name of Customer");
  236. gotoxy(8,20); printf("5/Search by No_of_Room");
  237. char ch1; ch1=getch(); clrscr();
  238.  
  239. switch(ch1)
  240. {
  241. case'1':gotoxy(5,3);
  242. printf("For Searching!!! Enter Customer ID="); scanf("%d",&si);
  243. j=0;
  244. clrscr();
  245. for(i=0;i<ID;i++)
  246. {if(cust[i].id==si)
  247. {
  248. f=1;
  249. gotoxy(1,11+(j*2));
  250. gotoxy(1,11+(j*2)); printf("%03d",cust[i].id);
  251. gotoxy(8,11+(j*2)); printf("%s",cust[i].name);
  252. gotoxy(23,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_in.day,cust[i].da_in.month,cust[i].da_in.year);
  253. gotoxy(38,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_out.day,cust[i].da_out.month,cust[i].da_out.year);
  254. gotoxy(57,11+(j*2)); printf("%d",cust[i].n_of_room);
  255. gotoxy(69,11+(j*2)); printf("%c",cust[i].room);
  256. gotoxy(73,11+(j*2)); printf("%d.00$",cust[i].price);
  257. j++;
  258. }
  259. }
  260. gotoxy(1,11+(j*2)); printf("==============================================================================");
  261. break;
  262. case'2':gotoxy(5,3);
  263. printf("For Searching!!! Enter Customer Date Check In=");
  264. scanf("%d%c%d%c%d",&d,&a,&m,&b,&y);
  265. j=0;
  266. clrscr();
  267. for(i=0;i<ID;i++)
  268. {if(cust[i].da_in.day==d && cust[i].da_in.month==m && cust[i].da_in.year==y)
  269. {
  270. f=1;
  271. gotoxy(1,11+(j*2));
  272. gotoxy(1,11+(j*2)); printf("%03d",cust[i].id);
  273. gotoxy(8,11+(j*2)); printf("%s",cust[i].name);
  274. gotoxy(23,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_in.day,cust[i].da_in.month,cust[i].da_in.year);
  275. gotoxy(38,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_out.day,cust[i].da_out.month,cust[i].da_out.year);
  276. gotoxy(57,11+(j*2)); printf("%d",cust[i].n_of_room);
  277. gotoxy(69,11+(j*2)); printf("%c",cust[i].room);
  278. gotoxy(73,11+(j*2)); printf("%d.00$",cust[i].price);
  279. j++;
  280. }
  281. }
  282. gotoxy(1,11+(j*2)); printf("==============================================================================");
  283. break;
  284. case'3':gotoxy(5,3);
  285. printf("For Searching!!! Enter Customer Date Check Out=");
  286. scanf("%d%c%d%c%d",&d,&a,&m,&b,&y);
  287. j=0;
  288. clrscr();
  289. for(i=0;i<ID;i++)
  290. {if(cust[i].da_out.day==d && cust[i].da_out.month==m && cust[i].da_out.year==y)
  291. {
  292. f=1;
  293. gotoxy(1,11+(j*2));
  294. gotoxy(1,11+(j*2)); printf("%03d",cust[i].id);
  295. gotoxy(8,11+(j*2)); printf("%s",cust[i].name);
  296. gotoxy(23,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_in.day,cust[i].da_in.month,cust[i].da_in.year);
  297. gotoxy(38,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_out.day,cust[i].da_out.month,cust[i].da_out.year);
  298. gotoxy(57,11+(j*2)); printf("%d",cust[i].n_of_room);
  299. gotoxy(69,11+(j*2)); printf("%c",cust[i].room);
  300. gotoxy(73,11+(j*2)); printf("%d.00$",cust[i].price);
  301. j++;
  302. }
  303. }
  304. gotoxy(1,11+(j*2)); printf("==============================================================================");
  305. break;
  306. case'4':gotoxy(5,3);
  307. printf("For Searching!!! Enter Customer Name=");
  308. fflush(stdin); gets(sn);
  309. j=0;
  310. clrscr();
  311. for(i=0;i<ID;i++)
  312. {if(strcmp(cust[i].name,sn)==0)
  313. {
  314. f=1;
  315. gotoxy(1,11+(j*2));
  316. gotoxy(1,11+(j*2)); printf("%03d",cust[i].id);
  317. gotoxy(8,11+(j*2)); printf("%s",cust[i].name);
  318. gotoxy(23,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_in.day,cust[i].da_in.month,cust[i].da_in.year);
  319. gotoxy(38,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_out.day,cust[i].da_out.month,cust[i].da_out.year);
  320. gotoxy(57,11+(j*2)); printf("%d",cust[i].n_of_room);
  321. gotoxy(69,11+(j*2)); printf("%c",cust[i].room);
  322. gotoxy(73,11+(j*2)); printf("%d.00$",cust[i].price);
  323. j++;
  324. }
  325. }
  326. gotoxy(1,11+(j*2)); printf("==============================================================================");
  327. break;
  328. case'5':gotoxy(5,3);
  329. printf("For Searching!!! Enter Room Number="); scanf("%d",&room);
  330. j=0;
  331. clrscr();
  332. for(i=0;i<ID;i++)
  333. {if(cust[i].n_of_room==room)
  334. {
  335. f=1;
  336. gotoxy(1,11+(j*2));
  337. gotoxy(1,11+(j*2)); printf("%03d",cust[i].id);
  338. gotoxy(8,11+(j*2)); printf("%s",cust[i].name);
  339. gotoxy(23,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_in.day,cust[i].da_in.month,cust[i].da_in.year);
  340. gotoxy(38,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_out.day,cust[i].da_out.month,cust[i].da_out.year);
  341. gotoxy(57,11+(j*2)); printf("%d",cust[i].n_of_room);
  342. gotoxy(69,11+(j*2)); printf("%c",cust[i].room);
  343. gotoxy(73,11+(j*2)); printf("%d.00$",cust[i].price);
  344. j++;
  345. }
  346. }
  347. gotoxy(1,11+(j*2)); printf("==============================================================================");
  348. break;
  349. default: gotoxy(3,27); printf("Error Enter Again!!");getch(); goto again;
  350. }
  351. if(f==0) {clrscr(); gotoxy(20,20); printf("Can not Find!!!");
  352. getch(); goto again;}
  353. gotoxy(30,3); printf("List of Customer");
  354. gotoxy(1,7); printf("ID");
  355. gotoxy(8,7); printf("Name");
  356. gotoxy(24,7); printf("Check_in");
  357. gotoxy(39,7); printf("Check_out");
  358. gotoxy(54,7); printf("NO_of_Room");
  359. gotoxy(67,7); printf("room");
  360. gotoxy(74,7); printf("Price");
  361. gotoxy(1,9); printf("==============================================================================");
  362. gotoxy(80,50);getch();
  363. }

Share this article :