Advertisement
asiffff

Untitled

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