Advertisement
asiffff

FinalProject

Apr 3rd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <windows.h>
  5. #include <conio.h>
  6. double total1=0.00,gpa1=0.00;
  7. struct student
  8. {
  9. int id;
  10. int cla;
  11. long int p_num;
  12. char group[20];
  13. char name[20];
  14. char name1[20];
  15. char gender[20];
  16. double bangla,english,math,reli,physics,chemistry,biology,acconting,economics,finance,sceince,ict,bgs,gpa,total;
  17. struct student *next,*prev;
  18. }*start=NULL,*end=NULL,*current;
  19.  
  20. void create()
  21. {
  22. char na[20];
  23. if(start==NULL && end==NULL)
  24. {
  25. struct student *new_node;
  26. new_node=(struct student*)malloc(1*sizeof(struct student));
  27. printf("Enter First Name: ");
  28. scanf("%s",&new_node->name);
  29. printf("\nEnter Last Name: ");
  30. scanf("%s",&new_node->name1);
  31. printf("\nEnter Gender: ");
  32. scanf("%s",&new_node->gender);
  33. printf("\nEnter Class: ");
  34. scanf("%d",&new_node->cla);
  35. printf("\nEnter ID: ");
  36. scanf("%d",&new_node->id);
  37. new_node->gpa = 0.00;
  38. new_node->total=0.00;
  39. if(new_node->cla ==9 || new_node->cla ==10)
  40. {
  41. printf("\nEnter Group: ");
  42. scanf("%s",&new_node->group);
  43. }
  44. else
  45. {
  46. char ec[10] = "NULL";
  47. strcpy(new_node->group,ec);
  48. }
  49. printf("\nEnter Parents Phone Number: ");
  50. scanf("%ld",&new_node->p_num);
  51. new_node->next=NULL;
  52. new_node->prev=NULL;
  53. start=new_node;
  54. end=new_node;
  55. current=new_node;
  56. system("cls");
  57. }
  58. else
  59. {
  60. struct student *new_node;
  61. new_node=(struct student*)malloc(1*sizeof(struct student));
  62. printf("Enter First Name: ");
  63. scanf("%s",&new_node->name);
  64. printf("\nEnter Last Name: ");
  65. scanf("%s",&new_node->name1);
  66. printf("\nEnter Gender: ");
  67. scanf("%s",&new_node->gender);
  68. printf("\nEnter Class: ");
  69. scanf("%d",&new_node->cla);
  70. new_node->gpa = 0.00;
  71. new_node->total=0.00;
  72. printf("\nEnter ID: ");
  73. scanf("%d",&new_node->id);
  74. if(new_node->cla ==9 || new_node->cla ==10)
  75. {
  76. printf("\nEnter Group: ");
  77. scanf("%s",&new_node->group);
  78. }
  79. else
  80. {
  81. char ec[10] = "NULL";
  82. strcpy(new_node->group,ec);
  83. }
  84. printf("\nEnter Parents Phone Number: ");
  85. scanf("%ld",&new_node->p_num);
  86. new_node->next=NULL;
  87. new_node->prev=NULL;
  88. current->next=new_node;
  89. new_node->prev=current;
  90. end=new_node;
  91. current=new_node;
  92. system("cls");
  93. }
  94. }
  95. void dis(int a)
  96. {
  97. int n=0,i=1;
  98. struct student *c;
  99. c=start;
  100. printf("\t Name Gender ID Group CGPA\n");
  101. printf("\t ---- ------ -- ----- ----\n\n");
  102. while(c!=NULL)
  103. {
  104. if(c->cla==a)
  105. {
  106.  
  107. printf("\t%s %s %s %d %s %.2lf\n",c->name,c->name1,c->gender,c->id,c->group,c->gpa);
  108.  
  109.  
  110. n++;
  111. }
  112. c=c->next;
  113. }
  114. //return n;
  115. if(n==0)
  116. printf("\n\nThere is no student in this Class\n");
  117. else
  118. printf("\n\nTotal Student %d\n",n);
  119. }
  120.  
  121. struct teacher
  122. {
  123. int id;
  124. char name[20];
  125. char name1[20];
  126. char gender[20];
  127. char group[20];
  128. long int phnum;
  129. struct teacher *next,*prev;
  130.  
  131. }*start1=NULL,*end1=NULL,*current1;
  132. void create1()
  133. {
  134. struct teacher *new_node;
  135. if(start1==NULL && end1==NULL)
  136. {
  137. new_node=(struct teacher*)malloc(1*sizeof(struct teacher));
  138. printf("Enter First Name: ");
  139. scanf("%s",&new_node->name);
  140. printf("\nEnter Last Name: ");
  141. scanf("%s",&new_node->name1);
  142. printf("\nEnter ID: ");
  143. scanf("%d",&new_node->id);
  144. printf("\nEnter Group: ");
  145. scanf("%s",&new_node->group);
  146. printf("\nEnter Gender: ");
  147. scanf("%s",&new_node->gender);
  148. printf("\nEnter Phone Number: ");
  149. scanf("%ld",&new_node->phnum);
  150. new_node->next=NULL;
  151. new_node->prev=NULL;
  152.  
  153. start1=new_node;
  154. end1=new_node;
  155. current1=new_node;
  156. system("cls");
  157.  
  158. }
  159. else
  160. {
  161. new_node=(struct teacher*)malloc(1*sizeof(struct teacher));
  162. printf("Enter First Name: ");
  163. scanf("%s",&new_node->name);
  164. printf("\nEnter Last Name: ");
  165. scanf("%s",&new_node->name1);
  166. printf("\nEnter ID: ");
  167. scanf("%d",&new_node->id);
  168. printf("\nEnter Group: ");
  169. scanf("%s",&new_node->group);
  170. printf("\nEnter Gender: ");
  171. scanf("%s",&new_node->gender);
  172. printf("\nEnter Phone Number: ");
  173. scanf("%ld",&new_node->phnum);
  174. new_node->next=NULL;
  175. new_node->prev=NULL;
  176.  
  177. current1->next=new_node;
  178. new_node->prev=current1;
  179. current1=new_node;
  180. end1=new_node;
  181. system("cls");
  182. }
  183.  
  184.  
  185.  
  186. }
  187. void dis1()
  188. {
  189. struct teacher *c;
  190. c=start1;
  191. while(c!=NULL)
  192. {
  193. printf("Teacher ID:%d\n",c->id);
  194. printf("Your group:%s\n",c->group);
  195. printf("Teacher Name:%s %s\n",c->name,c->name1);
  196. printf("Teacher Gender:%s\n",c->gender);
  197. printf("Teacher Phone number:%ld\n",c->phnum);
  198. c=c->next;
  199. }
  200. }
  201. int search(int a,int y)
  202. {
  203. struct student *c;
  204. struct teacher *c1;
  205. int po=0;
  206. if(a!=0 && y!=0)
  207. {
  208. c=start;
  209. while(c!=NULL)
  210. {
  211. po++;
  212. if(c->cla==a && c->id)
  213. {
  214. return po;
  215. }
  216. c=c->next;
  217. }
  218. return -1;
  219. }
  220. else
  221. {
  222. c1=start1;
  223. while(c1!=NULL)
  224. {
  225. po++;
  226. if(c1->id==a)
  227. {
  228. return po;
  229. }
  230. c1=c1->next;
  231. }
  232. return -1;
  233.  
  234. }
  235. }
  236. void print1()
  237. {
  238. printf("\n\n\n");
  239. printf("\t\t\t1.Enter Student Details.\n");
  240. printf("\t\t\t2.View All Student Details\n");
  241. printf("\t\t\t3.Search Student Details.\n");
  242. printf("\t\t\t4.Enter Teacher Details.\n");
  243. printf("\t\t\t5.View All Teacher Details\n");
  244. printf("\t\t\t6.Search Teacher Details.\n");
  245. printf("\t\t\t7.Enter Student Results\n");
  246. printf("\t\t\t8.View Student Result\n");
  247. printf("\t\t\t9.Exit.\n");
  248. }
  249. void print2()
  250. {
  251. printf("\n\n\n");
  252. //printf("\t\t\t1.Enter Student Details.\n");
  253. printf("\t\t\t1.View All Student Details\n");
  254. //printf("\t\t\t3.Search Student Details.\n");
  255. //printf("\t\t\t4.Enter Teacher Details.\n");
  256. printf("\t\t\t2.View All Teacher Details\n");
  257. printf("\t\t\t3.Search Teacher Details.\n");
  258. //printf("\t\t\t7.Enter Student Results\n");
  259. printf("\t\t\t4.View Student Result\n");
  260. printf("\t\t\t5.Exit.\n");
  261. }
  262. void cls()
  263. {
  264. system("cls");
  265. }
  266.  
  267. void print()
  268. {
  269. int i;
  270. printf(" ");
  271. for(i=1; i<=59; i++)
  272. {
  273. printf("* ");
  274. }
  275. printf("\n\n");
  276. printf("\t\t\t\t\tDAFFODIL INTERNATIONAL SCHOOL\n\n");
  277. printf(" ");
  278. for(i=1; i<=59; i++)
  279. {
  280. printf("* ");
  281. }
  282. printf("\n");
  283. }
  284. void admin_and_student(int z)
  285. {
  286. int exit = 0,x;
  287. while(1)
  288. {
  289.  
  290. if(exit==1)
  291. {
  292. break;
  293. }
  294. //int x;
  295. cls();
  296. print();
  297. if(z==1)
  298. {
  299. print1();
  300. }
  301. else if(z==2)
  302. {
  303. print2();
  304. }
  305. scanf("%d",&x);
  306. if(z==2)
  307. {
  308. if(x==1)
  309. x=2;
  310. else if(x==2)
  311. x=5;
  312. else if(x==3)
  313. x=6;
  314. else if(x==4)
  315. x=8;
  316. else if(x==5)
  317. x=9;
  318. }
  319. switch(x)
  320. {
  321. case 1:
  322. {
  323. while(1)
  324. {
  325. system("cls");
  326. print();
  327. create();
  328. print();
  329. printf("\t\tDo you want to continue?\n");
  330. printf("1.Yes 2.No\n");
  331. int e;
  332. scanf("%d",&e);
  333. if(e==1)
  334. continue;
  335. else
  336. break;
  337. }
  338. system("cls");
  339. break;
  340. }
  341. case 2:
  342. {
  343. system("cls");
  344. print();
  345. printf("\t\t\t\t1.Class 6\n\t\t\t\t2.Class 7.\n\t\t\t\t3.Class 8.\n\t\t\t\t4.Class 9.\n\t\t\t\t5.Class 10.\n");
  346. int e;
  347. scanf("%d",&e);
  348. system("cls");
  349. switch(e)
  350. {
  351. case 1:
  352. {
  353. system("cls");
  354. print();
  355. dis(6);
  356. getch();
  357. system("cls");
  358. break;
  359. }
  360. case 2:
  361. {
  362. system("cls");
  363. print();
  364. dis(7);
  365. getch();
  366. system("cls");
  367. break;
  368. }
  369. case 3:
  370. {
  371. system("cls");
  372. print();
  373. dis(8);
  374. getch();
  375. break;
  376. }
  377. case 4:
  378. {
  379. system("cls");
  380. print();
  381. dis(9);
  382. getch();
  383. break;
  384. }
  385. case 5:
  386. {
  387. system("cls");
  388. print();
  389. dis(10);
  390. getch();
  391. break;
  392. }
  393. }
  394. //dis();
  395. print();
  396. printf("\n\n\nPress any key to quit.");
  397. getch();
  398. system("cls");
  399. break;
  400. }
  401. case 3:
  402. {
  403. while(1)
  404. {
  405. system("cls");
  406. print();
  407. int x1,y1;
  408. printf("\n\n\nEnter Class: ");
  409. scanf("%d",&x1);
  410. printf("\nEnter Student ID: ");
  411. scanf("%d",&y1);
  412. system("cls");
  413. //print();
  414. int pos = search(x1,y1);
  415. if(pos==-1)
  416. {
  417. print();
  418. printf("\n\n\nNot Found");
  419. getch();
  420. system("cls");
  421. }
  422. else
  423. {
  424. print();
  425. struct student *b;
  426. b=start;
  427. int j;
  428. for(j=0; j<pos-1; j++)
  429. {
  430. b=b->next;
  431. }
  432. if(b->cla == 9 || b->cla == 10)
  433. {
  434. printf("\n\n\nName : %s %s\nGender : %s\nClass : %d\nID : %d\nGroup : %s\nParents Number : %ld\n",b->name,b->name1,b->gender,b->cla,b->id,b->group,b->p_num);
  435. }
  436. else
  437. {
  438. printf("\n\n\nName : %s %s\nGender : %s\nClass : %d\nID : %d\nParents Number : %ld\n",b->name,b->name1,b->gender,b->cla,b->id,b->p_num);
  439. }
  440. printf("\n\nPress any key.");
  441. getch();
  442. system("cls");
  443. }
  444. print();
  445. printf("\n\n\nDo you want to search another?\n 1.Yes 2.No\n");
  446. int e;
  447. scanf("%d",&e);
  448. if(e==1)
  449. continue;
  450. else if(e==2)
  451. break;
  452.  
  453. }
  454. system("cls");
  455. break;
  456. }
  457. case 4:
  458. {
  459. while(1)
  460. {
  461. system("cls");
  462. print();
  463. create1();
  464. int e;
  465. print();
  466. printf("\n\n\nDo you want to Continue?\n1.Yes 2.No\n");
  467. scanf("%d",&e);
  468. if(e==1)
  469. continue;
  470. else if(e==2)
  471. break;
  472. }
  473. system("cls");
  474. break;
  475. }
  476. case 5:
  477. {
  478. system("cls");
  479. print();
  480. dis1();
  481. getch();
  482. system("cls");
  483. break;
  484. }
  485. case 6:
  486. {
  487. while(1)
  488. {
  489. system("cls");
  490. print();
  491. printf("\n\n\nEnter Id:\n");
  492. int k;
  493. scanf("%d",&k);
  494. int pos1 = search(k,0);
  495. if(pos1==-1)
  496. {
  497. system("cls");
  498. print();
  499. printf("\n\n\nNot Found\n");
  500. getch();
  501. system("cls");
  502. }
  503. else
  504. {
  505. system("cls");
  506. print();
  507. struct teacher *c;
  508. c=start1;
  509. int j;
  510. for(j=0; j<pos1-1; j++)
  511. {
  512. c=c->next;
  513. }
  514. printf("\n\n\nTeacher Name :%s\n",c->name);
  515. printf("\nTeacher ID :%d",c->id);
  516. printf("\nGroup :%s",c->group);
  517. printf("\nTeacher Gender :%s",c->gender);
  518. printf("\nPhone number :%ld",c->phnum);
  519. getch();
  520. system("cls");
  521.  
  522. }
  523. print();
  524. printf("\n\n\nDo you want to continue?\n1.Yes 2.No\n");
  525. int e;
  526. scanf("%d",&e);
  527. if(e==1)
  528. continue;
  529. else
  530. break;
  531. }
  532. system("cls");
  533. break;
  534. }
  535. case 7:
  536. {
  537. while(1)
  538. {
  539. system("cls");
  540. print();
  541. int x1,y1;
  542. printf("\n\n\nEnter Class: ");
  543. scanf("%d",&x1);
  544. printf("\nEnter Student ID: ");
  545. scanf("%d",&y1);
  546. system("cls");
  547. int k;
  548. //y=2;
  549. int pos1 = search(x1,y1);
  550. if(pos1==-1)
  551. {
  552. system("cls");
  553. print();
  554. printf("\n\n\nNot Found\n");
  555. getch();
  556.  
  557. }
  558. else
  559. {
  560. print();
  561. total1 = 0.00;
  562. gpa1 = 0.00;
  563. struct student *c;
  564. c=start;
  565. int j,k=0;
  566. for(j=0; j<pos1-1; j++)
  567. {
  568. c=c->next;
  569. }
  570. printf("\n\n\nName : %s %s\n",c->name,c->name1);
  571. printf("Bangla : ");
  572. scanf("%lf",&c->bangla);
  573. gpa(c->bangla);
  574. printf("\nEnglish: ");
  575. scanf("%lf",&c->english);
  576. gpa(c->english);
  577. printf("\nMath: ");
  578. scanf("%lf",&c->math);
  579. gpa(c->math);
  580. if(strcmp(c->group,"Science") == 0 || strcmp(c->group,"science") == 0)
  581. {
  582. printf("\nPhysics: ");
  583. scanf("%lf",&c->physics);
  584. gpa(c->physics);
  585. printf("\nChemistry: ");
  586. scanf("%lf",&c->chemistry);
  587. gpa(c->chemistry);
  588. printf("\nBiology: ");
  589. scanf("%lf",&c->biology);
  590. gpa(c->biology);
  591. }
  592. else if(strcmp(c->group,"Commerce") ==0 || strcmp(c->group,"commerce") == 0)
  593. {
  594. printf("\nAccounting: ");
  595. scanf("%lf",&c->acconting);
  596. gpa(c->acconting);
  597. printf("\nFinance And Banking: ");
  598. scanf("%lf",&c->finance);
  599. gpa(c->finance);
  600. printf("\nEconomics: ");
  601. scanf("%lf",&c->economics);
  602. gpa(c->economics);
  603. }
  604. else
  605. {
  606. printf("\nScience: ");
  607. scanf("%lf",&c->sceince);
  608. gpa(c->sceince);
  609. printf("\nICT: ");
  610. scanf("%lf",&c->ict);
  611. gpa(c->ict);
  612. printf("\nBangladesh And Global Studies: ");
  613. scanf("%lf",&c->bgs);
  614. gpa(c->bgs);
  615. }
  616. printf("\nReligion: ");
  617. scanf("%lf",&c->reli);
  618. gpa(c->reli);
  619. //getch();
  620. c->total = total1;
  621. c->gpa = gpa1/7.00;
  622. getch();
  623. system("cls");
  624. }
  625. int e;
  626. print();
  627. printf("\n\nDo you want to continue?\n1.Yes 2.No\n");
  628. scanf("%d",&e);
  629. if(e==1)
  630. continue;
  631. else
  632. break;
  633.  
  634. }
  635. system("cls");
  636. break;
  637. }
  638. case 8:
  639. {
  640. while(1)
  641. {
  642. system("cls");
  643. print();
  644. int x1,y1;
  645. printf("\n\nEnter Class: ");
  646. scanf("%d",&x1);
  647. printf("\nEnter Student ID: ");
  648. scanf("%d",&y1);
  649. system("cls");
  650. int k;
  651. int pos1 = search(x1,y1);
  652. if(pos1==-1)
  653. {
  654. printf("Not Found\n");
  655. getch();
  656. system("cls");
  657. }
  658. else
  659. {
  660. system("cls");
  661. struct student *c;
  662. c=start;
  663. int j;
  664. for(j=0; j<pos1-1; j++)
  665. {
  666. c=c->next;
  667. }
  668. print();
  669.  
  670. if(c->cla==9 || c->cla==10)
  671. {
  672. printf("\n\nName : %s %s Group: %s\nClass : %d Roll : %d\n",c->name,c->name1,c->group,c->cla,c->id);
  673. }
  674. else
  675. {
  676. printf("\n\nName : %s %s Class : %d Roll : %d\n",c->name,c->name1,c->cla,c->id);
  677. }
  678. printf("Bangla : %.2lf",c->bangla);
  679. printf("\n\nEnglish: %.2lf",c->english);
  680.  
  681. printf("\n\nMath: %.2lf\n",c->math);
  682.  
  683. if(strcmp(c->group,"Science") == 0 || strcmp(c->group,"science") == 0)
  684. {
  685.  
  686. printf("\nPhysics: %.2lf\n",c->physics);
  687.  
  688. printf("\nChemistry: %.2lf\n",c->chemistry);
  689.  
  690. printf("\nBiology: %.2lf\n",c->biology);
  691. }
  692. else if(strcmp(c->group,"Commerce") ==0 || strcmp(c->group,"commerce") == 0)
  693. {
  694. printf("\n\nAccounting: %.2lf",c->acconting);
  695. printf("\n\nFinance And Banking: %.2lf",c->finance);
  696. printf("\n\nEconomics: %.2lf",c->economics);
  697. }
  698. else
  699. {
  700. printf("\n\nScience: %.2lf",c->sceince);
  701. printf("\n\nICT: %.2lf",c->ict);
  702. printf("\n\nBangladesh And Global Studies: %.2lf",c->bgs);
  703. }
  704. printf("\nReligion: %.2lf\n",c->reli);
  705. printf("\n\nTotal Number: %.2lf GPA: %.2lf\n",c->total,c->gpa);
  706.  
  707. getch();
  708. system("cls");
  709.  
  710. }
  711. int e;
  712. print();
  713. printf("Do you want to continue?\n1.Yes 2.No\n");
  714. scanf("%d",&e);
  715. if(e==1)
  716. continue;
  717. else if(e==2)
  718. break;
  719. }
  720. system("cls");
  721. break;
  722.  
  723.  
  724. }
  725. case 9:
  726. {
  727. exit = 1;
  728. break;
  729. }
  730.  
  731. }
  732. }
  733. }
  734. void gpa(double n)
  735. {
  736. total1 = total1 + n;
  737. if(n>=80)
  738. {
  739. gpa1 = gpa1 + 5.00;
  740. }
  741. else if(n>=70 && n<80)
  742. {
  743. gpa1 = gpa1 + 4.00;
  744. }
  745. else if(n>=60 && n<70)
  746. {
  747. gpa1 = gpa1 + 3.50;
  748. }
  749. else if(n>=50 && n<60)
  750. {
  751. gpa1 = gpa1 + 3.00;
  752. }
  753. else if(n>=40 && n<50)
  754. {
  755. gpa1 = gpa1 + 2.00;
  756. }
  757. else if(n>=33 && n<40)
  758. {
  759. gpa1 = gpa1 + 0.00;
  760. }
  761. }
  762. void admin()
  763. {
  764. int d=0;
  765. char c[10],p[10];
  766. while(1)
  767. {
  768.  
  769. system("cls");
  770. print();
  771. if(d==1)
  772. {
  773. system("cls");
  774. print();
  775. printf("\t\t\tWrong Password! Try again.");
  776. }
  777. printf("\n\n\n");
  778. printf("\t\t\t\tEnter User Name: ");
  779. scanf("%s",c);
  780. printf("\n");
  781. printf("\t\t\t\tEnter Password: ");
  782. scanf("%s",&p);
  783. if(strcmp(c,"techy5")==0 && strcmp(p,"121172")==0)
  784. {
  785. system("cls");
  786. print();
  787. printf("\t\t\tWelcome To Daffodil International School.\n\n\n");
  788. printf("\t\t\tPress any key to enter in the Admin Panel\n");
  789. getch();
  790. system("cls");
  791. break;
  792. }
  793. else
  794. {
  795. system("cls");
  796. d=1;
  797. //printf("Wrong Password! Try again.\n");
  798. continue;
  799. }
  800. }
  801. }
  802.  
  803. int main()
  804. {
  805. int x,y,ex=0,d=0;
  806. char c[10],p[10];
  807. while(1)
  808. {
  809. if(ex==1)
  810. {
  811. break;
  812. }
  813. cls();
  814. print();
  815. printf("\n\n\n");
  816. printf("1.Admin Panel.\n\n2.Student Panel.\n\n3.Exit.\n\n");
  817. scanf("%d",&x);
  818. switch(x)
  819. {
  820. case 1:
  821. {
  822. admin();
  823. //getch();
  824. admin_and_student(1);
  825. break;
  826.  
  827. }
  828. case 2:
  829. {
  830. admin_and_student(2);
  831. break;
  832. }
  833. case 3:
  834. {
  835. cls();
  836. print();
  837. printf("Thank You.\n");
  838. getch();
  839. ex=1;
  840. break;
  841. }
  842. }
  843. }
  844. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement