Advertisement
Mahfuz123

Mredul's project

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