Advertisement
Mahfuz123

Mitul's Project

Nov 24th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. void information();
  6. void book_room();
  7.  
  8. struct node
  9. {
  10. char room_num[10];
  11. char name[30];
  12. char phone_number[15];
  13. char national_id[20];
  14. char day[10];
  15. struct node *next;
  16. }*head = NULL;
  17.  
  18. void empty_room()
  19. {
  20.  
  21. }
  22.  
  23. void room_type()
  24. {
  25.  
  26. }
  27.  
  28. void book_room()
  29. {
  30. FILE *fp, *f;
  31. int i,a,b,temp, system,num;
  32. char room[]=".txt";
  33. struct node *new_node, *current;
  34.  
  35. while(1)
  36. {
  37. new_node = (struct node*)malloc(sizeof(struct node));
  38. new_node->next = NULL;
  39.  
  40.  
  41.  
  42. printf("Enter your choice what you want to do:\n");
  43. printf("1 for searching empty room\n");
  44. printf("2 for types of room\n");
  45. printf("3 room booking\n");
  46. printf("4 for searching customer details\n");
  47. printf("5 for food service\n");
  48. printf("6 for billing system\n");
  49. printf("7 for check out\n");
  50. printf("\nEnter : ");
  51. scanf("%d", &system);
  52. if (system==3)
  53. {
  54. printf("Enter the room no : ");
  55. scanf(" %[^\n]", new_node->room_num);
  56. strcat(new_node->room_num, room);
  57.  
  58. fp = fopen(new_node->room_num, "w");
  59. if(fp == NULL){
  60. perror("This room is already booked");
  61. return EXIT_FAILURE;
  62. }
  63. else{
  64. printf("Enter your name : ");
  65. getchar();
  66. fprintf(fp, gets(new_node->name));
  67. fprintf(fp, "\n");
  68. printf("Enter your mobile no : ");
  69. fprintf(fp, gets(new_node->phone_number));
  70. fprintf(fp, "\n");
  71. printf("Enter national id no : ");
  72. fprintf(fp, gets(new_node->national_id));
  73. fprintf(fp, "\n");
  74. printf("How many days you want to stay here : ");
  75. fprintf(fp, gets(new_node->day));
  76. fprintf(fp, "\n");
  77. fclose(fp);
  78.  
  79. if(head == NULL){
  80. head = new_node;
  81. current = new_node;
  82. }
  83. else{
  84. current->next = new_node;
  85. current = new_node;
  86. }
  87. }
  88. printf("\nThanks for staying us, Your room is booked successfully :-)\n");
  89. }
  90. else if (system==2)
  91. {
  92. room_type();
  93. }
  94.  
  95. else if (system==4)
  96. {
  97. //customer_details();
  98. information();
  99. }
  100.  
  101. else if (system==5)
  102. {
  103. food_service();
  104. }
  105.  
  106. else if (system==6)
  107. {
  108. billing();
  109. }
  110.  
  111. else if (system==6)
  112. {
  113. check_out();
  114. }
  115.  
  116. else
  117. {
  118. printf("Wrong choice. Please insert a correct value\n\n\n");
  119. }
  120.  
  121. }
  122.  
  123. }
  124.  
  125. void customer_details()
  126. {
  127.  
  128. }
  129.  
  130. void food_service()
  131. {
  132.  
  133. }
  134.  
  135. void billing()
  136. {
  137.  
  138. }
  139.  
  140. void check_out()
  141. {
  142.  
  143. }
  144.  
  145. void information()
  146. {
  147. FILE *fp;
  148. char ch;
  149. struct node *current;
  150.  
  151. current = head;
  152.  
  153. while(current != NULL){
  154. printf("%s\n", current->room_num);
  155. fp = fopen(current->room_num, "r");
  156.  
  157. while(1){
  158. ch = fgetc(fp);
  159. if(ch==EOF){
  160. break;
  161. }
  162. putchar(ch);
  163. }
  164. current = current->next;
  165.  
  166. }
  167. }
  168.  
  169. int main()
  170. {
  171. printf(" Our Hotel Management System\n <--------------------------->\n\n\n");
  172.  
  173. book_room();
  174. information();
  175.  
  176. return 0;
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement