S_h_u_v_r_o

p

Apr 12th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.84 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<string.h>
  4. #include<stdlib.h>
  5.  
  6. typedef struct src
  7. {
  8. char name[30];
  9. char id[15];
  10.  
  11. float marksds;
  12. float marksec;
  13. float marksdm;
  14. float marksde;
  15.  
  16. float gpds;
  17. float gpec;
  18. float gpdm;
  19. float gpde;
  20.  
  21. char gradeds[3];
  22. char gradeec[3];
  23. char gradedm[3];
  24. char gradede[3];
  25.  
  26. char commentds[20];
  27. char commentec[20];
  28. char commentdm[20];
  29. char commentde[20];
  30.  
  31. float gp;
  32. char comment[30];
  33.  
  34. struct src *ptr;
  35. } src;
  36.  
  37. src *head=NULL,*temp,*x;
  38.  
  39. float final(char c[],float a,float b,float i,float j)
  40. {
  41. float e=(a+b+i+j)/4;
  42.  
  43. if(e==4.00)
  44. {
  45. strcpy(c,"Outstanding");
  46. }
  47. else if(e<4.00&&e>=3.75)
  48. {
  49. strcpy(c,"Excellent");
  50. }
  51. else if(e<3.75&&e>=3.50)
  52. {
  53. strcpy(c,"Very Good");
  54. }
  55. else if(e<3.50&&e>=3.25)
  56. {
  57. strcpy(c,"Good");
  58. }
  59. else if(e<3.25&&e>=3.00)
  60. {
  61. strcpy(c,"Satisfactory");
  62. }
  63.  
  64. else if(e<3.00&&e>=2.75)
  65. {
  66. strcpy(c,"Above Average");
  67. }
  68. else if(e<2.75&&e>=2.50)
  69. {
  70. strcpy(c,"Average");
  71. }
  72. else if(e<2.50&&e>=2.25)
  73. {
  74. strcpy(c,"Bellow Average");
  75. }
  76. else if(e<2.25&&e>=2.00)
  77. {
  78. strcpy(c,"Pass");
  79. }
  80. else if(e<2.00&&e>=0.00)
  81. {
  82. strcpy(c,"Fail");
  83. }
  84.  
  85. return e;
  86. }
  87.  
  88. float grade(char c[],char d[],float a)
  89. {
  90. if(a>=80&&a<=100)
  91. {
  92. strcpy(c,"A+");
  93. strcpy(d,"Outstanding");
  94. return 4;
  95. }
  96. else if(a>=75.00&&a<=79.00)
  97. {
  98. strcpy(c,"A");
  99. strcpy(d,"Excellent");
  100. return 3.75;
  101. }
  102. else if(a>=70&&a<=74)
  103. {
  104. strcpy(c,"A-");
  105. strcpy(d,"Very Good");
  106. return 3.50;
  107. }
  108. else if(a>=65&&a<=69)
  109. {
  110. strcpy(c,"B+");
  111. strcpy(d,"Good");
  112. return 3.25;
  113. }
  114. else if(a>=60&&a<=64)
  115. {
  116. strcpy(c,"B");
  117. strcpy(d,"Satisfactory");
  118. return 3;
  119. }
  120.  
  121. else if(a>=55&&a<=59)
  122. {
  123. strcpy(c,"B-");
  124. strcpy(d,"Avobe Average");
  125. return 2.75;
  126. }
  127. else if(a>=50&&a<=54)
  128. {
  129. strcpy(c,"C+");
  130. strcpy(d,"Average");
  131. return 2.50;
  132. }
  133. else if(a>=45&&a<=49)
  134. {
  135. strcpy(c,"C");
  136. strcpy(d,"Bellow Average");
  137. return 2.25;
  138. }
  139. else if(a>=40&&a<=44)
  140. {
  141. strcpy(c,"D");
  142. strcpy(d,"Pass");
  143. return 2;
  144. }
  145. else if(a>=0&&a<=39)
  146. {
  147. strcpy(c,"F");
  148. strcpy(d,"Fail");
  149. return 0;
  150. }
  151. }
  152.  
  153. void insertion()
  154. {
  155. while(1)
  156. {
  157. x=(src*)malloc(sizeof(src));
  158.  
  159. printf("\nEnter The Name: ");
  160. scanf(" %[^\n]s",&x->name);
  161.  
  162. printf("Enter The Id : ");
  163. scanf(" %[^\n]s",&x->id);
  164.  
  165. printf("\nEnter The Marks:\n");
  166. printf("----------------\n");
  167.  
  168. printf("Marks For Data Structure : ");
  169. scanf("%f",&x->marksds);
  170. x->gpds=grade(x->gradeds,x->commentds,x->marksds);
  171.  
  172. printf("Marks For Electrical Circuit : ");
  173. scanf("%f",&x->marksec);
  174. x->gpec=grade(x->gradeec,x->commentec,x->marksec);
  175.  
  176. printf("Marks For Discrete Math : ");
  177. scanf("%f",&x->marksdm);
  178. x->gpdm=grade(x->gradedm,x->commentdm,x->marksdm);
  179.  
  180. printf("Marks For Differential Equation: ");
  181. scanf("%f",&x->marksde);
  182. x->gpde=grade(x->gradede,x->commentde,x->marksde);
  183.  
  184. x->gp=final(x->comment,x->gpds,x->gpec,x->gpdm,x->gpde);
  185.  
  186. x->ptr=NULL;
  187. printf("-------------------------------------------------------------------------------");
  188.  
  189. if(head==NULL)
  190. {
  191. head=x;
  192. }
  193. else
  194. {
  195. temp=head;
  196. while(temp->ptr!=NULL)
  197. {
  198. temp=temp->ptr;
  199. }
  200. temp->ptr=x;
  201. }
  202.  
  203. printf("\n\t\t\tContinue Getting Information(Y/N)");
  204. printf("\n-------------------------------------------------------------------------------");
  205.  
  206. char ch=getch();
  207. if(ch=='N'||ch=='n')
  208. {
  209. break;
  210. }
  211. }
  212. main2();
  213. }
  214.  
  215. void printall()
  216. {
  217. int c;
  218. printf("\n ----------");
  219. printf("\n ALL RECORD:");
  220. printf("\n ----------");
  221.  
  222. temp=head;
  223.  
  224. if(temp==NULL)
  225. {
  226. printf("\n\t\t\tRecord Empty.\n");
  227. }
  228.  
  229. while(temp!=NULL)
  230. {
  231. printf("\n Student Name: %s\n Student Id : %s\n\n",temp->name,temp->id);
  232. printf(" Course Title\t\t Grade\t Grade Point\t Comment\n");
  233. printf(" ------------\t\t -----\t -----------\t -------\n");
  234.  
  235. if(temp->gradeds[1]=='+'||temp->gradeds[1]=='-')
  236. {
  237. printf(" Data Structure\t\t %s %.2f %s\n",temp->gradeds,temp->gpds,temp->commentds);
  238. }
  239. else
  240. {
  241. printf(" Data Structure\t\t %s %.2f %s\n",temp->gradeds,temp->gpds,temp->commentds);
  242. }
  243. if(temp->gradeec[1]=='+'||temp->gradeec[1]=='-')
  244. {
  245. printf(" Electrical Circuit\t %s %.2f %s\n",temp->gradeec,temp->gpec,temp->commentec);
  246. }
  247. else
  248. {
  249. printf(" Electrical Circuit\t %s %.2f %s\n",temp->gradeec,temp->gpec,temp->commentec);
  250. }
  251. if(temp->gradedm[1]=='+'||temp->gradedm[1]=='-')
  252. {
  253. printf(" Discrete Math \t\t %s %.2f %s\n",temp->gradedm,temp->gpdm,temp->commentdm);
  254. }
  255. else
  256. {
  257. printf(" Discrete Math \t\t %s %.2f %s\n",temp->gradedm,temp->gpdm,temp->commentdm);
  258. }
  259. if(temp->gradede[1]=='+'||temp->gradede[1]=='-')
  260. {
  261. printf(" Differential Equation\t %s %.2f %s\n\n",temp->gradede,temp->gpde,temp->commentde);
  262. }
  263. else
  264. {
  265. printf(" Differential Equation\t %s %.2f %s\n\n",temp->gradede,temp->gpde,temp->commentde);
  266. }
  267. printf("\n\t\t\t SGPA= %.2f\t\t %s\n",temp->gp,temp->comment);
  268.  
  269. temp=temp->ptr;
  270. printf("-------------------------------------------------------------------------------\n");
  271.  
  272. }
  273.  
  274. printf("\n-------------------------------------------------------------------------------\n");
  275. printf("\t\t\tMAIN MENU OR TERMINATE(M/T)");
  276. printf("\n-------------------------------------------------------------------------------\n");
  277. char ch=getch();
  278. if(ch=='M'||ch=='m')
  279. {
  280.  
  281. main2();
  282. }
  283. }
  284.  
  285. void search()
  286. {
  287. int b=0;
  288. char d[30];
  289. printf("\nEnter The Id: ");
  290. scanf(" %[^\n]s",&d);
  291. printf("-------------------------------------------------------------------------------\n");
  292.  
  293. temp=head;
  294. while(temp!=NULL)
  295. {
  296. if(strcmp(temp->id,d)==0)
  297.  
  298. {
  299. b=1;
  300. break;
  301. }
  302. else
  303. {
  304. temp=temp->ptr;
  305. }
  306.  
  307. }
  308. if(b==0)
  309. {
  310. printf("Record Not Found\n");
  311. }
  312. else
  313. {
  314. printf("\n Student Name: %s\n Student Id : %s\n\n",temp->name,temp->id);
  315.  
  316. printf(" Course Title\t\t Grade\t Grade Point\t Comment\n");
  317. printf(" ------------\t\t -----\t -----------\t -------\n");
  318.  
  319. if(temp->gradeds[1]=='+'||temp->gradeds[1]=='-')
  320. {
  321. printf(" Data Structure\t\t %s %.2f %s\n",temp->gradeds,temp->gpds,temp->commentds);
  322. }
  323. else
  324. {
  325. printf(" Data Structure\t\t %s %.2f %s\n",temp->gradeds,temp->gpds,temp->commentds);
  326. }
  327. if(temp->gradeec[1]=='+'||temp->gradeec[1]=='-')
  328. {
  329. printf(" Electrical Circuit\t %s %.2f %s\n",temp->gradeec,temp->gpec,temp->commentec);
  330. }
  331. else
  332. {
  333. printf(" Electrical Circuit\t %s %.2f %s\n",temp->gradeec,temp->gpec,temp->commentec);
  334. }
  335. if(temp->gradedm[1]=='+'||temp->gradedm[1]=='-')
  336. {
  337. printf(" Discrete Math \t\t %s %.2f %s\n",temp->gradedm,temp->gpdm,temp->commentdm);
  338. }
  339. else
  340. {
  341. printf(" Discrete Math \t\t %s %.2f %s\n",temp->gradedm,temp->gpdm,temp->commentdm);
  342. }
  343. if(temp->gradede[1]=='+'||temp->gradede[1]=='-')
  344. {
  345. printf(" Differential Equation\t %s %.2f %s\n\n",temp->gradede,temp->gpde,temp->commentde);
  346. }
  347. else
  348. {
  349. printf(" Differential Equation\t %s %.2f %s\n\n",temp->gradede,temp->gpde,temp->commentde);
  350. }
  351.  
  352.  
  353. printf("\n\t\t\t SGPA= %.2f\t\t %s\n",temp->gp,temp->comment);
  354. printf("-------------------------------------------------------------------------------\n");
  355. }
  356. printf("-------------------------------------------------------------------------------\n");
  357. printf("\t\t\tMAIN MENU OR CONTINUE(M/C)");
  358. char ch=getch();
  359. if(ch=='C'||ch=='c')
  360. {
  361. printf("\n-------------------------------------------------------------------------------\n");
  362. search();
  363. }
  364. else
  365. {
  366. main2();
  367. }
  368.  
  369. }
  370. int help(char d[])
  371. {
  372. int b=0;
  373. temp=head;
  374. while(temp!=NULL)
  375. {
  376. if(strcmp(temp->id,d)==0)
  377.  
  378. {
  379. b=1;
  380. break;
  381. }
  382. else
  383. {
  384. temp=temp->ptr;
  385. }
  386. }
  387.  
  388. return b;
  389.  
  390. }
  391.  
  392. void delete()
  393. {
  394. char d[30];
  395. int b=0,c;
  396. src *temp1;
  397. printf("\nEnter The Id: ");
  398. scanf(" %[^\n]s",&d);
  399. printf("----------------\n");
  400. c=help(d);
  401. if(c==0)
  402. {
  403. printf(" Unsuccesful\n");
  404. goto bue;
  405. }
  406.  
  407. temp=head;
  408. if(strcmp(head->id,d)==0)
  409. {
  410. head=head->ptr;
  411. free(temp);
  412. b=1;
  413. }
  414.  
  415. temp=head;
  416. while(temp!=NULL)
  417. {
  418. if(strcmp(temp->id,d)==0)
  419. {
  420. b=1;
  421. temp1->ptr=temp->ptr;
  422. free(temp);
  423. break;
  424. }
  425. else
  426. {
  427. temp1=temp;
  428. temp=temp->ptr;
  429. }
  430.  
  431. }
  432. if(b==0)
  433. {
  434. printf(" Unsuccesful\n");
  435. }
  436. else
  437. {
  438. printf(" Succesful\n");
  439. }
  440.  
  441. bue:
  442.  
  443. printf("-------------------------------------------------------------------------------\n");
  444. printf("\t\t\tMAIN MENU OR CONTINUE(M/C)");
  445. char ch=getch();
  446. if(ch=='c'||ch=='C')
  447. {
  448. printf("\n-------------------------------------------------------------------------------\n");
  449. delete();
  450. }
  451. else
  452. {
  453. main2();
  454. }
  455. }
  456.  
  457. void main2()
  458. {
  459.  
  460. int a;
  461. printf("\n-------------------------------------------------------------------------------");
  462. printf("\n\t 1. For Adding Student Information.\n");
  463. printf("\t 2. For Deleting Student Information.\n");
  464. printf("\t 3. For Displaying All Student Information.\n");
  465. printf("\t 4. For Displaying Specific Student Information.\n");
  466. printf("\t 5. For Closing The Program");
  467. printf("\n-------------------------------------------------------------------------------");
  468. printf("\nChoose The Operation: ");
  469. scanf(" %d",&a);
  470. printf("-------------------------------------------------------------------------------");
  471.  
  472. if(a==1)
  473. {
  474. insertion();
  475. }
  476. else if(a==2)
  477. {
  478. delete();
  479. }
  480. else if(a==3)
  481. {
  482. printall();
  483. }
  484. else if(a==4)
  485. {
  486. search();
  487. }
  488. else if(a==5)
  489. {
  490. return 0;
  491. }
  492. }
  493.  
  494. int main()
  495. {
  496. system("COLOR 0B");
  497.  
  498. printf("\t\t\t---------------------\n");
  499. printf("\t\t\t STUDENT REPORT CARD\n");
  500. printf("\t\t\t---------------------\n");
  501.  
  502. main2();
  503.  
  504. return 0;
  505. }
Add Comment
Please, Sign In to add comment