Advertisement
Mahfuz123

Projectt.c

Nov 21st, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.40 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. int serial = 0;
  6. int token = 100;
  7. void search(int x);
  8. void create();
  9. void display();
  10.  
  11. struct node
  12. {
  13. char doctor_name[40];
  14. char disease_name[40];
  15. char degree_name[40];
  16. char time[40];
  17. char fees[20];
  18. int id;
  19. struct node *next;
  20. }*head = NULL;
  21.  
  22. void manage()
  23. {
  24. FILE *fp;
  25. struct node *current;
  26. int a,b,n,i,j,k;
  27. char name[100],blood[10], ch, location[100], ph[100];
  28.  
  29. while(1)
  30. {
  31. a = 0;
  32. printf("How can we help you ??\n");
  33. printf("1 for Doctor serial\n2 for Ambulance service\n3 for Emergency contact\n4 for Blood Bank\n5 for exit\n");
  34. scanf("%d", &n);
  35.  
  36. if(n==1){
  37. printf("\nOur Doctors :\n\n");
  38. display();
  39. printf("Enter Doctor Id for Serial : ");
  40. scanf("%d", &a);
  41. search(a);
  42. }
  43. else if(n==2){
  44. printf("Enter you location : ");
  45. getchar();
  46. gets(name);
  47. printf("We sent Ambulance at %s location. Here is our driver no : 01726-987565\n\n\n", name);
  48. }
  49. else if(n==3){
  50. printf("Please call us as soon as possible\nMobile: 01725-659874\n\n");
  51. }
  52. else if(n==4){
  53. char filename[] = "Document.txt";
  54. fp = fopen(filename, "w");
  55. fprintf(fp, "Blood Group : \nA+ --> 10 Bags\nA- --> 5 Bags\nB+ --> 10 Bags\nB- --> 5 Bags\nAB+ --> 7 Bags\nAB- --> 5 Bags\nO+ --> 10 Bags\nO- --> 15 Bags\n");
  56. fclose(fp);
  57.  
  58. fp = fopen(filename, "r");
  59. printf("Our Stock : \n");
  60. while(1){
  61. ch = fgetc(fp);
  62. if(ch == EOF){
  63. break;
  64. }
  65.  
  66. putchar(ch);
  67. }
  68. fclose(fp);
  69.  
  70.  
  71. while(1){
  72. printf("Which Blood group do you need : ");
  73. scanf(" %[^\n]", blood);
  74. if(strcmp(blood, "A+")==0 || strcmp(blood, "A-")==0 || strcmp(blood, "AB+")==0 || strcmp(blood, "AB-")==0 || strcmp(blood, "B+") ==0 || strcmp(blood, "B-") == 0 || strcmp(blood, "O+") == 0 || strcmp(blood, "O-")==0 )
  75. {
  76. printf("%s is Available\n", blood);
  77. break;
  78. }
  79. else{
  80. printf("Oops you enter a wrong blood group\n");
  81. continue;
  82. }
  83. }
  84.  
  85. printf("Enter the amount of bag , Location and your Phone number:\n");
  86. printf("Number of bag : ");
  87. scanf("%d", &b);
  88. printf("Location : ");
  89. getchar();
  90. gets(location);
  91. printf("Phone number : ");
  92. gets(ph);
  93. printf("\nWe sent your blood to your location : %s\nThanks for staying with us\n\n\n", location);
  94.  
  95.  
  96. }
  97. else if(n==5){
  98. break;
  99. }
  100. }
  101. }
  102.  
  103. void search(int x)
  104. {
  105. struct node *current;
  106. int t,ch,n,i,j,k;
  107. int a = 0;
  108. current = head;
  109. while(current != NULL){
  110.  
  111. if(current->id == x){
  112. a++;
  113. serial++;
  114. token++;
  115. printf("Choose method : \n1. Bikash\n2. Datch Bangla\n3. Nogod\n");
  116. scanf("%d", &n);
  117.  
  118. if(n==1){
  119. printf("Give amount through Bikash : ");
  120. scanf("%d", &i);
  121. }
  122. else if(n==2){
  123. printf("Give amount through Datch Bangla : ");
  124. scanf("%d", &j);
  125. }
  126. else if(n==3){
  127. printf("Give amount through Nogod : ");
  128. scanf("%d", &k);
  129. }
  130.  
  131. printf("Your Serial booked successfully\nYour serial no is : %d\nYour Token No is : %d\n", serial, token);
  132. printf("Please Contact us for more information\nMobile : 01856-789465\n\n");
  133. }
  134. current = current->next;
  135. }
  136. if(a==0){
  137. printf("Oops, You enter a wrong id, Please try again with valid id\n\n");
  138. printf("Enter Doctor id for serial : ");
  139. scanf("%d", &ch);
  140. search(ch);
  141. }
  142. }
  143. void create()
  144. {
  145. struct node *new_node, *current, *temp;
  146. int n,a,b;
  147.  
  148. new_node = (struct node*)malloc(sizeof(struct node));
  149. strcpy(new_node->doctor_name, "Dr.Mahfuzur Rahman");
  150. strcpy(new_node->disease_name, "Eye Specialist");
  151. strcpy(new_node->degree_name, "MBBS , Dhaka Medical College");
  152. strcpy(new_node->time, "Sat - Thu(8am - 10pm)");
  153. strcpy(new_node->fees, "500 tk");
  154. new_node->id = 110;
  155.  
  156.  
  157. head = new_node;
  158. current = new_node;
  159.  
  160. new_node = (struct node*)malloc(sizeof(struct node));
  161.  
  162. strcpy(new_node->doctor_name, "Dr. Mredul Hasan");
  163. strcpy(new_node->disease_name, "Cardiac Specialist");
  164. strcpy(new_node->degree_name, "MBBS , Dhaka Medical College");
  165. strcpy(new_node->time, "Sat - Mon(8am - 7pm)");
  166. strcpy(new_node->fees, "700 tk");
  167. new_node->id = 151;
  168.  
  169. current->next = new_node;
  170. current = new_node;
  171. new_node->next = NULL;
  172.  
  173. new_node = (struct node*)malloc(sizeof(struct node));
  174.  
  175. strcpy(new_node->doctor_name, "Dr. Asif Farhan");
  176. strcpy(new_node->disease_name, "Medicine");
  177. strcpy(new_node->degree_name, "MBBS, Dhaka Medical College");
  178. strcpy(new_node->time, "Sun - Thu(10am-5pm)");
  179. strcpy(new_node->fees, "700 tk");
  180. new_node->id = 211;
  181.  
  182. current->next = new_node;
  183. new_node->next = NULL;
  184. current = new_node;
  185.  
  186. new_node = (struct node*)malloc(sizeof(struct node));
  187.  
  188. strcpy(new_node->doctor_name, "Dr. Niloy Kumar Sarkar");
  189. strcpy(new_node->disease_name, "Gastrology specialist");
  190. strcpy(new_node->degree_name, "MBBS, Dhaka Medical College");
  191. strcpy(new_node->time, "Sun-Thu(8am-7pm)");
  192. strcpy(new_node->fees, "500 tk");
  193. new_node->id = 251;
  194.  
  195. current->next = new_node;
  196. new_node->next = NULL;
  197. current = new_node;
  198.  
  199.  
  200. }
  201.  
  202. void display()
  203. {
  204. struct node *current;
  205.  
  206. current = head;
  207.  
  208. while(current != NULL){
  209. printf("%s\n%s\n%s\n%s\nId = %d\nFees : %s\n",current->doctor_name, current->disease_name, current->degree_name, current->time, current->id, current->fees);
  210.  
  211. printf("\n\n");
  212. current = current->next;
  213. }
  214. }
  215.  
  216. int main()
  217. {
  218. printf("\n ----------------------->>>> Welcome to our Hospital <<<<------------------------\n\n");
  219. create();
  220. manage();
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement