Advertisement
Zahid_hasan

prjct ////last

Apr 10th, 2020
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<conio.h>
  3. #include<process.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. //sub main 3 function
  8. void admin();
  9. void teacher();
  10. void student();
  11.  
  12. //-----------------------------Student-----------------Part------------------
  13.  
  14. //Student information
  15. void input_student_details(); //check
  16. void input_student_result();
  17.  
  18. //Student search
  19. void student_search();
  20. void search_by_name_result();
  21. // void student_search_by_name();
  22. // void student_search_by_roll(); //check
  23.  
  24. //Display part
  25. void display_student_information();
  26. void display_student_information_result(); //check
  27.  
  28. //------------------------------Teacher------------------------------Part-----------------------
  29.  
  30. //teacher information
  31. void input_teacher_details(); //check
  32. //search
  33. void teacher_search();
  34. //void teacher_search_by_name();
  35. //void teacher_search_by_subject_name();
  36. //display teacher information
  37. void display_teacher_details();
  38.  
  39. //-----------------------------Admin----------------------------------Part--------------
  40.  
  41. void check(); //Checking mark
  42.  
  43. //void show_avareage_mark();
  44. void check_bangla_pass_fail();
  45. void check_english_pass_fail();
  46. void check_math_pass_fail();
  47. void check_social_science_pass_fail();
  48. void check_general_science_pass_fail();
  49.  
  50.  
  51. struct student
  52. {
  53. char name[30];
  54. int password[10];
  55. char cls[10];
  56. int Roll;
  57. char age[3];
  58. char subject_name[20];
  59. char counselling_time[20];
  60. //char counseling_date[10];
  61. int bangla_marks,english_marks,math_marks,socialScience_marks,generalScience_marks;
  62. char phone_no[11];
  63. float per;
  64. char grade;
  65. int std;
  66.  
  67. } information;
  68. //long si=sizeof(s);
  69.  
  70.  
  71. int main()
  72. {
  73. system("cls");
  74. system("color B");
  75.  
  76. int choice;
  77.  
  78. printf("\t\t\t\t\t*****GOPALPUR HIGH SCHOOL*****");
  79. printf("\n\t\t\t\t\t**School Management System**");
  80. printf("\n\t\t\t\t******************************************");
  81.  
  82. printf("\n\n\n\t\t\t\t\t1.Administrator Login");
  83. printf("\n\t\t\t\t\t2.Teacher Login");
  84. printf("\n\t\t\t\t\t3.Student Login");
  85. printf("\n\n\t\t\t\t\tPlease enter your choice: ");
  86. scanf("%d",&choice);
  87.  
  88. switch(choice)
  89. {
  90. case 0:
  91. exit(0);
  92. case 1:
  93. admin();
  94. break;
  95. case 2:
  96. teacher();
  97. break;
  98. case 3:
  99. student();
  100. break;
  101. default:
  102. printf("Errors");
  103. break;
  104. }
  105. return 0;
  106. }
  107. // user define function start....
  108.  
  109. //-----------------------------------Teacher------------Part-------------------------------------
  110.  
  111. FILE *fp01;
  112. void input_teacher_details()
  113. {
  114. system("cls");
  115. fp01=fopen("teacher.txt","ab");
  116. printf("Enter the teacher name: ");
  117. fflush(stdin);
  118. gets(information.name);
  119. printf("Enter the age: ");
  120. fflush(stdin);
  121. gets(information.age);
  122. printf("Enter the subject name: ");
  123. fflush(stdin);
  124. gets(information.subject_name);
  125. printf("Enter the counseling time : ");
  126. fflush(stdin);
  127. gets(information.counselling_time);
  128. printf("Enter the phone number: ");
  129. fflush(stdin);
  130. gets(information.phone_no);
  131.  
  132. fwrite(&information, sizeof(information),1,fp01);
  133. printf("Record save successfully\n");
  134. fclose(fp01);
  135. }
  136.  
  137. //FILE *file3;
  138. void teacher()
  139. {
  140. system("cls");
  141. char name[20],password[8];
  142. int i,choice;
  143. //file3=fopen("teacher.txt","a");
  144. //if(file3==NULL)
  145. //{
  146. // printf("File doesn't exists.");
  147. // return 0;
  148. // }else{
  149. printf("\n\t\t\t\t\t***Teacher***");
  150. printf("\n\t\t\t\tEnter your name: ");
  151. scanf("%s",&name);
  152. printf("\n\t\t\t\tEnter our password: ");
  153. for(i=0; i<6; i++)
  154. {
  155. password[i]=getch();
  156. printf("*");
  157. }
  158. password[i]='\0';
  159. if(strcmp(name,"hasan")==0 && strcmp(password,"mehedi")==0)
  160. {
  161. printf("\n\n\t\t\t\t\t1.Input Teacher details");
  162. printf("\n\t\t\t\t\t2.Display Teacher Information");
  163. printf("\n\t\t\t\t\t3.Display Student Information");
  164. printf("\n\t\t\t\t\t4.Display Student Information & Result");
  165. printf("\n\t\t\t\t\t5.Search A Teacher");
  166. printf("\n\t\t\t\t\t6.Search A Student");
  167. printf("\n\t\t\t\t\t7.Check");
  168. printf("\n\t\t\t\t\t8.Back To Main Menu");
  169. printf("\n\t\t\t\tEnter your choice: ");
  170. scanf("%d",&choice);
  171. switch(choice)
  172. {
  173. case 0:
  174. exit(0);
  175. case 1:
  176. input_teacher_details();
  177. break;
  178. case 2:
  179. display_teacher_details();
  180. break;
  181. case 3:
  182. display_student_information();
  183. break;
  184. case 4:
  185. display_student_information_result();
  186. break;
  187. case 5:
  188. teacher_search();
  189. break;
  190. case 6:
  191. student_search();
  192. break;
  193. case 7:
  194. check();
  195. break;
  196. case 8:
  197. system("cls");
  198. main();
  199. break;
  200. default: printf("Error");
  201. }
  202. }
  203. else
  204. printf("Check your name or password...");
  205. // }
  206. // fclose(file3);
  207. }
  208.  
  209. void display_teacher_details()
  210. {
  211. system("cls");
  212. printf("<== Teacher Information ==>\n\n");
  213. printf("%-30s %-20s %-20s %-20s\t %s\n","Name","Age","Subject","Counseling_Time","Phone_No");
  214. fp01 = fopen("teacher.txt","rb");
  215. while(fread(&information ,sizeof(information) ,1,fp01)==1)
  216. {
  217. printf("%-30s %-20s %-20s %-20s\t %s\n",information.name ,information.age ,information.subject_name, information.counselling_time ,information.phone_no);
  218. }
  219. fclose(fp01);
  220. printf("Press any key to continue...");
  221. }
  222.  
  223.  
  224.  
  225. void teacher_search()
  226. {
  227. system("cls");
  228. char na[30];
  229. int f=0;
  230. printf("Enter Name to search: ");
  231. fflush(stdin);
  232. gets(na);
  233. printf("%-30s %-20s %-20s %-20s\t %s\n","Name","Age","Subject","Counseling_Time","Phone_No");
  234. fp01=fopen("teacher.txt","rb");
  235. while(fread(&information,sizeof(information),1,fp01)==1)
  236. {
  237. if(strcmp(na,information.name)==0)
  238. {
  239. f=1;
  240. printf("%-30s %-20s %-20s %-20s\t %s\n",information.name ,information.age ,information.subject_name ,information.counselling_time ,information.phone_no);
  241. printf("Record Found Successfully...\n");
  242. printf("Press any key to continue...\n\n");
  243. break;
  244. }
  245. }
  246. fclose(fp01);
  247. if(f==0)
  248. printf("Record Not Found...\n");
  249. }
  250.  
  251.  
  252.  
  253.  
  254. //-------------------------------Student------------part--------------------------------------------
  255. FILE *file2;
  256. void student()
  257. {
  258. system("cls");
  259. char name[20],password[8],ch='*';
  260. int i, choice;
  261. file2=fopen("student.txt","rb");
  262. if(file2==NULL)
  263. {
  264. printf("File doesn't exists");
  265. return;
  266. }
  267. printf("\n\t\t\t\t\t***Student***\n");
  268. printf("\n\t\t\t\tEnter your name: ");
  269. scanf("%s",&name);
  270. printf("\n\t\t\t\tEnter your password: ");
  271. for(i=0; i<5; i++)
  272. {
  273. password[i]=getch();
  274. printf("*");
  275. }
  276. password[i]='\0';
  277. if(strcmp(name,"zahid")==0 && strcmp(password,"mahdi")==0)
  278. {
  279.  
  280. printf("\n\n\t\t\t\t\t***Student Login Successfully***\n");
  281. while(1)
  282. {
  283. printf("\n\n\t\t\t\t\t1. Display Teacher Information ");
  284. printf("\n\t\t\t\t\t2. Search A Teacher");
  285. printf("\n\t\t\t\t\t3. View Your Information");
  286. printf("\n\t\t\t\t\t4. View Your Information & Result");
  287. printf("\n\t\t\t\t\t5. Back To Main Menu");
  288. printf("\n\t\t\t\tEnter your choice: ");
  289. scanf("%d",&choice);
  290. switch(choice)
  291. {
  292. case 0:
  293. exit(0);
  294. case 1:
  295. display_teacher_details();
  296. break;
  297.  
  298. case 2:
  299. teacher_search();
  300. break;
  301. case 3:
  302. student_search();
  303. break;
  304. case 4:
  305. search_by_name_result();
  306. break;
  307. case 5:
  308. system("cls");
  309. main();
  310. break;
  311. default:
  312. printf("Error");
  313. break;
  314.  
  315. }
  316. }
  317. }
  318. else
  319. printf("\n Check Your Name Or Password...\n");
  320. fclose(file2);
  321. }
  322.  
  323.  
  324. FILE *fp02;
  325. void input_student_details()
  326. {
  327. system("cls");
  328. fp02=fopen("student.txt","ab+");
  329. printf("Enter the student name: ");
  330. fflush(stdin);
  331. gets(information.name);
  332. printf("Enter the class: ");
  333. gets(information.cls);
  334. printf("Enter the roll: ");
  335. scanf("%d",&information.Roll);
  336. printf("Enter the age: ");
  337. scanf("%d",&information.age);
  338. fflush(stdin);
  339. printf("Enter the guardian phone no.: ");
  340. gets(information.phone_no);
  341.  
  342. fwrite(&information, sizeof(information),1,fp02);
  343. printf("Record successfully\n");
  344. fclose(fp02);
  345. }
  346.  
  347. FILE *fp03;
  348. void input_student_result()
  349. {
  350. system("cls");
  351. fp03=fopen("result.txt","ab+");
  352. printf("Enter Student Name: ");
  353. fflush(stdin);
  354. gets(information.name);
  355. printf("Enter Class: ");
  356. scanf("%s",&information.cls);
  357. printf("Enter roll: ");
  358. scanf("%d",&information.Roll);
  359. printf("\nEnter The marks in Bangla out of 100 : ");
  360. scanf("%d",&information.bangla_marks);
  361. printf("\nEnter The marks in English out of 100 : ");
  362. scanf("%d",&information.english_marks);
  363. printf("\nEnter The marks in Mathematics out of 100 : ");
  364. scanf("%d",&information.math_marks);
  365. printf("\nEnter The marks in Social Science out of 100 : ");
  366. scanf("%d",&information.socialScience_marks);
  367. printf("\nEnter The marks in General Science out of 100 : ");
  368. scanf("%d",&information.generalScience_marks);
  369.  
  370. information.per=(information.bangla_marks +information.english_marks +information.math_marks +information.socialScience_marks +information.generalScience_marks)/5.0;
  371.  
  372.  
  373. fwrite(&information, sizeof(information),1,fp03);
  374. printf("Record Saved Successfully");
  375. fclose(fp03);
  376. }
  377.  
  378. void display_student_information()
  379. {
  380. system("cls");
  381. printf("<== Student Information ==>\n\n");
  382. printf("%s\t\t %s\t\t %s\t\t %s\n","Name","Class","Roll","Guardian_Number");
  383. fp02= fopen("student.txt","rb");
  384. while(fread(&information,sizeof(information),1,fp02)==1)
  385. {
  386. printf("%s\t\t %s\t\t %d\t\t %d\t\t %s\n",information.name ,information.cls ,information.Roll,information.phone_no);
  387. }
  388. fclose(fp02);
  389. printf("Press any key to continue...");
  390. }
  391.  
  392. void display_student_information_result()
  393. {
  394. system("cls");
  395.  
  396. printf("\n\n\n\t\tDISPLAY ALL RECORD !!!\n\n");
  397. fp03=fopen("result.txt","rb+");
  398. while((fread(&information,sizeof(information),1,fp03))>0)
  399. {
  400.  
  401. printf("\nName of student : %s",information.name);
  402. printf("\nName of class : %s",information.cls);
  403. printf("\nNumber of roll : %d",information.Roll);
  404. printf("\n\nMarks in Bangla : %d",information.bangla_marks);
  405. printf("\nMarks in English : %d",information.english_marks);
  406. printf("\nMarks in Mathematics : %d",information.math_marks);
  407. printf("\nMarks in Social Science : %d",information.socialScience_marks);
  408. printf("\nMarks in General Science : %d",information.generalScience_marks);
  409. printf("\nPercentage of student is : %.2f",information.per);
  410.  
  411. printf("\n\n====================================\n");
  412.  
  413. printf("Press any key to continue...");
  414.  
  415. getch();
  416. }
  417. fclose(fp03);
  418. }
  419.  
  420.  
  421. void student_search()
  422.  
  423. {
  424. system("cls");
  425. char na[30];
  426. int f=0;
  427. printf("Enter Name to search: ");
  428. fflush(stdin);
  429. gets(na);
  430. printf("%s\t\t %s\t\t %s\t\t %s\t\t %s\n","Name","Class","Roll","Age","Guardian_Number");
  431. fp02=fopen("student.txt","rb");
  432. while(fread(&information,sizeof(information),1,fp02)==1)
  433. {
  434. if(strcmpi(na,information.name)==0)
  435. {
  436. f=1;
  437. printf("%s\t\t %s\t\t %d\t\t %d\t\t %s\n",information.name ,information.cls ,information.Roll ,information.age ,information.phone_no);
  438. printf("Record Found Successfully...\n");
  439. printf("Press any key to continue...\n\n");
  440. break;
  441. }
  442. }
  443. fclose(fp02);
  444. if(f==0)
  445. printf("Record Not Found...\n");
  446. }
  447.  
  448. void search_by_name_result()
  449. {
  450.  
  451. system("cls");
  452. char na[30];
  453. int f=0;
  454. printf("Enter Name to search: ");
  455. fflush(stdin);
  456. gets(na);
  457. fp03=fopen("result.txt","rb+");
  458. while((fread(&information,sizeof(information),1,fp03))>0)
  459. {
  460. if(strcmpi(na,information.name)==0)
  461.  
  462. printf("\nName of student : %s",information.name);
  463. printf("\nName of class : %s",information.cls);
  464. printf("\nNumber of roll : %d",information.Roll);
  465. printf("\n\nMarks in Bangla : %d",information.bangla_marks);
  466. printf("\nMarks in English : %d",information.english_marks);
  467. printf("\nMarks in Mathematics : %d",information.math_marks);
  468. printf("\nMarks in Social Science : %d",information.socialScience_marks);
  469. printf("\nMarks in General Science : %d",information.generalScience_marks);
  470. printf("\nPercentage of student is : %.2f",information.per);
  471.  
  472. printf("\n\n====================================\n");
  473.  
  474. printf("Press any key to continue...");
  475.  
  476. getch();
  477. break;
  478. }
  479. fclose(fp03);
  480. if(f==0)
  481. printf("Record Not Found...\n");
  482.  
  483.  
  484.  
  485.  
  486.  
  487. }
  488.  
  489. //-----------------------------------Admin-----Part----------------------------------------------------------------
  490. FILE *file1;
  491. void admin()
  492. {
  493. system("color A");
  494. system("cls");
  495. int choice,i;
  496. char name[20],password[8];
  497. file1=fopen("Administrators.txt","wb");
  498. if(file1==NULL)
  499. {
  500. printf("There is no exist file\n");
  501. return 0;
  502. }
  503.  
  504. printf("\t\t\t\t\tFor Administrator\n");
  505. printf("\n\t\t\t\tEnter your name: ");
  506. scanf("%s",name);
  507. printf("\n\t\t\t\tEnter the password: ");
  508. for(i=0; i<5;i++)
  509. {
  510. password[i]=getch();
  511. printf("*");
  512. }
  513. password[i]='\0';
  514. fwrite(&information, sizeof(information),1,file1);
  515. if(strcmp(name,"zahid")==0 && strcmp(password,"hasan")==0 )
  516. {
  517. printf("\n\n\t\t\t\tAdmin Login Successfully");
  518. while(1)
  519. {
  520. printf("\n\n\t\t\t\t\t1. Display teachers detail");
  521. printf("\n\t\t\t\t\t2. Search a teacher");
  522. printf("\n\t\t\t\t\t3. Student information input & editing");
  523. printf("\n\t\t\t\t\t4. Student information and result input and editing");
  524. printf("\n\t\t\t\t\t5. Display student information");
  525. printf("\n\t\t\t\t\t6. Display student information and result");
  526. printf("\n\t\t\t\t\t7. Search a student");
  527. printf("\n\t\t\t\t\t8. Check");
  528. printf("\n\t\t\t\t\t9. Back To Main Menu");
  529.  
  530. fwrite(&information, sizeof(information),1,file1);
  531.  
  532. printf("\n\n Please enter your choice:");
  533. scanf("%d",&choice);
  534. switch(choice)
  535. {
  536. case 0:
  537. exit (0);
  538. case 1:
  539. display_teacher_details();
  540. break;
  541. case 2:
  542. teacher_search();
  543. break;
  544. case 3:
  545. input_student_details();
  546. break;
  547. case 4:
  548. input_student_result();
  549. break;
  550. case 5:
  551. display_student_information();
  552. break;
  553. case 6:
  554. display_student_information_result();
  555. break;
  556. case 7:
  557. student_search();
  558. break;
  559. case 8:
  560. check();
  561. break;
  562. case 9:
  563. system("cls");
  564. main();
  565. break;
  566. default:
  567. printf("errors");
  568. }
  569. }
  570. }
  571.  
  572. else
  573. {
  574. printf("\t\tCheck your name or password...\n");
  575. }
  576.  
  577. fclose(file1);
  578.  
  579. }
  580.  
  581. void check()
  582. {
  583. system("cls");
  584. int ch;
  585.  
  586. while(1)
  587. {
  588.  
  589. printf("<== Varsity Management ==>\n");
  590. printf("<== Check ==>\n\n");
  591. printf("1.Check Bangla pass fail\n");
  592. printf("2.Check English pass fail \n");
  593. printf("3.Check Mathematics pass fail\n");
  594. printf("4.Check Social Science pass fail\n");
  595. printf("5.Check General Science pass fail\n");
  596. printf("6.Back To Admin menu\n");
  597. printf("\n\nEnter your choice: ");
  598. scanf("%d",&ch);
  599.  
  600. switch(ch)
  601. {
  602.  
  603. case 1:
  604. check_bangla_pass_fail();
  605. break;
  606. case 2:
  607. check_english_pass_fail();
  608. break;
  609. case 3:
  610. check_math_pass_fail();
  611. break;
  612. case 4:
  613. check_social_science_pass_fail();
  614. break;
  615. case 5:
  616. check_general_science_pass_fail();
  617. break;
  618.  
  619. case 6:
  620. system("cls");
  621. admin();
  622. break;
  623.  
  624. default:
  625. printf("Invalid Choice");
  626. }
  627. getch();
  628. }
  629. }
  630.  
  631.  
  632. void check_bangla_pass_fail()
  633. {
  634. system("cls");
  635.  
  636. float result[10],greatest;
  637.  
  638. int i =0;
  639. int f=0;
  640. int n;
  641. int count1=0,count2=0;
  642. printf("Total student: \n");
  643. scanf("%d",&n);
  644. printf("The Bangla results are:\n");
  645.  
  646. for (i = 1; i < n+1; i++)
  647. {
  648. printf("The %dst student result is:\n",i);
  649. scanf("%f", &result[i]);
  650. }
  651.  
  652. for (i = 1; i < n+1; i++)
  653. {
  654. if(result[i]>33)
  655. count1++;
  656. else
  657. count2++;
  658.  
  659. }
  660. printf("Total pass in Bangla is: %d\n",count1);
  661. printf("Total fail in Bangla is: %d\n\n",count2);
  662.  
  663. printf("Press any key to continue...\n\n");
  664. }
  665.  
  666. void check_english_pass_fail()
  667. {
  668. system("cls");
  669.  
  670. float result[10],greatest;
  671.  
  672. int i =0;
  673. int f=0;
  674. int n;
  675. int count1=0,count2=0;
  676. printf("Total student: \n");
  677. scanf("%d",&n);
  678. printf("The English results are:\n");
  679.  
  680. for (i = 1; i < n+1; i++)
  681. {
  682. printf("The %dst student result is:\n",i);
  683. scanf("%f", &result[i]);
  684. }
  685.  
  686. for (i = 1; i < n+1; i++)
  687. {
  688. if(result[i]>33)
  689. count1++;
  690. else
  691. count2++;
  692.  
  693. }
  694.  
  695.  
  696. printf("Total pass in Math is: %d\n",count1);
  697. printf("Total fail in Math is: %d\n\n",count2);
  698.  
  699. printf("Press any key to continue...\n\n");
  700. }
  701.  
  702.  
  703. void check_math_pass_fail()
  704. {
  705. system("cls");
  706.  
  707. float result[10],greatest;
  708.  
  709. int i =0;
  710. int f=0;
  711. int n;
  712. int count1=0,count2=0;
  713. printf("Total student: \n");
  714. scanf("%d",&n);
  715. printf("The Mathematics results are:\n");
  716.  
  717. for (i = 1; i < n+1; i++)
  718. {
  719. printf("The %dst student result is:\n",i);
  720. scanf("%f", &result[i]);
  721. }
  722.  
  723. for (i = 1; i < n+1; i++)
  724. {
  725. if(result[i]>33)
  726. count1++;
  727. else
  728. count2++;
  729.  
  730. }
  731.  
  732. printf("Total pass in Mathematics is: %d\n",count1);
  733. printf("Total fail in Mathematics is: %d\n\n",count2);
  734.  
  735. printf("Press any key to continue...\n\n");
  736. }
  737.  
  738.  
  739. void check_social_science_pass_fail()
  740. {
  741. system("cls");
  742.  
  743. float result[10],greatest;
  744.  
  745. int i =0;
  746. int f=0;
  747. int n;
  748. int count1=0,count2=0;
  749. printf("Total student: \n");
  750. scanf("%d",&n);
  751. printf("The Social Science results are:\n");
  752.  
  753. for (i = 1; i < n+1; i++)
  754. {
  755. printf("The %dst student result is:\n",i);
  756. scanf("%f", &result[i]);
  757. }
  758.  
  759. for (i = 1; i < n+1; i++)
  760. {
  761. if(result[i]>33)
  762. count1++;
  763. else
  764. count2++;
  765.  
  766. }
  767. printf("Total pass in Social Science is: %d\n",count1);
  768. printf("Total fail in Social Science is: %d\n\n",count2);
  769.  
  770. printf("Press any key to continue...\n\n");
  771. }
  772.  
  773. void check_general_science_pass_fail()
  774. {
  775. system("cls");
  776.  
  777. float result[10],greatest;
  778.  
  779. int i =0;
  780. int f=0;
  781. int n;
  782. int count1=0,count2=0;
  783. printf("Total student: \n");
  784. scanf("%d",&n);
  785. printf("The General Science results are:\n");
  786.  
  787. for (i = 1; i < n+1; i++)
  788. {
  789. printf("The %dst student result is:\n",i);
  790. scanf("%f", &result[i]);
  791. }
  792.  
  793. for (i = 1; i < n+1; i++)
  794. {
  795. if(result[i]>33)
  796. count1++;
  797. else
  798. count2++;
  799.  
  800. }
  801.  
  802. printf("Total pass in General science is: %d\n",count1);
  803. printf("Total fail in General Science is: %d\n\n",count2);
  804.  
  805. printf("Press any key to continue...\n\n");
  806. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement