Advertisement
Zahid_hasan

final project

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