Advertisement
asiffff

Untitled

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