Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 12.98 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. int introduction(char studentList[75][25], int numStd);
  6. void marks(char studentList[75][25], int markI[], int markII[], int markIII[], int numStd, char code[5]);
  7. int menushow(char studentList[75][25], int markI[], int markII[], int markIII[], int numStd, char code[5]);
  8. void bufferclr();
  9. void marksask(char studentList[][25],  int markI[], int markII[], int markIII[], int numStd, char code[5]);
  10. void marktable(char studentList[][25],  int markI[], int markII[], int markIII[], int numStd, char code[5]);
  11. void setToZero(int markI[], int markII[], int markIII[]);
  12. void modeSvr(char code[5], char studentList[75][25], int markI[], int markII[], int markIII[], int numStd);
  13. void pinswap(char code[5], char studentList[][25], int markI[], int markII[], int markIII[], int numStd);
  14. void changemark(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[5]);
  15. void studentadd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[5]);
  16. void changename(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[5]);
  17. void searchstd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[5]);
  18. void swapname(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[5]);
  19. void thefinale();
  20. void markcorrection(char studentList[][25],  int markI[], int markII[], int markIII[], int numStd, char code[5]);
  21. void showstd(char studentList[][25],  int markI[], int markII[], int markIII[], int numStd, char code[5]);
  22. void charensure();
  23. void intensure();
  24. void main()
  25. {  
  26.     char studentList[75][25], code[5]="6969";
  27.     int numStd, markI[75], markII[75], markIII[75];
  28.     int option;
  29.     setToZero(markI, markII, markIII);
  30.     numStd = introduction(studentList, numStd);
  31.     while(option != 4)
  32.     {
  33.     option = menushow(studentList, markI, markII, markIII, numStd, code);
  34.     }
  35. }
  36. int introduction(char studentList[][25], int numStd)
  37. {  
  38.     int next;
  39.     printf("Enter number of students: ");
  40.     scanf("%i", &numStd);
  41.     bufferclr();
  42.     /*Store the Students*/
  43.     for(next=0; next<numStd; next++){
  44.             printf("Enter the student name of No.%i: \n", next);
  45.             scanf("%24s", &studentList[next]);
  46.             bufferclr();
  47.     }
  48.     return numStd;
  49. }
  50. int menushow(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
  51. {  
  52.     int menunum;
  53.     printf("\n\n                         MAIN MENU                              \n"
  54.                 "//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n"
  55.                 "//                                                           //\n"
  56.                 "//                     1 Enter marks                         //\n"
  57.                 "//                                                           //\n"
  58.                 "//           2 Display A Particular Student's Marks          //\n"
  59.                 "//                                                           //\n"
  60.                 "//                   3 Supervisor Mode                       //\n"
  61.                 "//                                                           //\n"
  62.                 "//                     4 Exit Program                        //\n"
  63.                 "//                                                           //\n"
  64.                 "//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n\n");
  65.     printf("              Where do you want to go? Type the number: ");
  66.     scanf("%i", &menunum); bufferclr();
  67.     switch(menunum){
  68.         case 1:
  69.             printf("//                     1 Enter marks                        \\ \n");
  70.             marks(studentList, markI, markII, markIII, numStd, code);
  71.             break;
  72.         case 2:
  73.             printf("//           2 Display A Particular Student's Marks        \\ \n");
  74.             showstd(studentList, markI, markII, markIII, numStd, code);
  75.             break;
  76.         case 3:
  77.             printf("//                   3 Supervisor Mode                      \\ \n");
  78.             modesvr(code, markI, markII, markIII, numStd);
  79.             break;
  80.         case 4:
  81.             printf("//                     4 Exit Program                       \\ \n");
  82.             thefinale();
  83.             break;
  84.     }
  85.     return menunum;
  86. }
  87. void marks(char studentList[][25],  int markI[], int markII[], int markIII[], int numStd, char code[])
  88. {
  89.     int coursemark, next, tag = 1;
  90.     printf("What coursework do you want to enter marks for? "), scanf("%i", &coursemark); bufferclr();
  91.     printf("------------------------------------------------ \n");
  92.     switch(coursemark){
  93.         case 1:
  94.     for(next=0; next<numStd; next++){
  95.     printf("Student: %s :", studentList[next]);
  96.     scanf("%i", &markI[next]); bufferclr();
  97. }
  98.     marksask(studentList, markI, markII, markIII, numStd, code);
  99.     break;
  100.         case 2:
  101.     for(next=0; next<numStd; next++){
  102.     printf("Student: %s :", studentList[next]);
  103.     scanf("%i", &markII[next]); bufferclr();
  104. }
  105.     marksask(studentList, markI, markII, markIII, numStd, code);
  106.     break;
  107.         case 3:
  108.     for(next=0; next<numStd; next++){
  109.     printf("Student: %s :", studentList[next]);
  110.     scanf("%i", &markIII[next]); bufferclr();
  111. }
  112.     marksask(studentList, markI, markII, markIII, numStd, code);
  113.     break;
  114.     default:
  115.     printf("INVALID INPUT");
  116.  }
  117. }
  118. void marksask(char studentList[][25],  int markI[], int markII[], int markIII[], int numStd, char code[])
  119. {
  120.     char ask;
  121.     printf("Enter marks for another coursework Y or N:"), scanf("%s", &ask);
  122.     switch (ask){
  123.         case 'y':
  124.             marktable(studentList, markI, markII, markIII, numStd, code);
  125.             markcorrection(studentList, markI, markII, markIII, numStd, code);
  126.             break;
  127.         case 'Y':
  128.             marktable(studentList, markI, markII, markIII, numStd, code);
  129.             markcorrection(studentList, markI, markII, markIII, numStd, code);
  130.             break;
  131.         case 'n':
  132.             marktable(studentList, markI, markII, markIII, numStd, code);
  133.             break;
  134.         case 'N':
  135.             marktable(studentList, markI, markII, markIII, numStd, code);
  136.             break;
  137.         default:
  138.             printf("INVALID INPUT");
  139.             marksask(studentList, markI, markII, markIII, numStd, code);
  140.     }
  141.    
  142. }
  143. void marktable(char studentList[][25],  int markI[], int markII[], int markIII[], int numStd, char code[])
  144. {
  145.     int next; char ask;
  146. /* Display the students */
  147.     for(next=0; next<numStd; next++){
  148.             printf("\n||------------------------------------- |");
  149.             printf("\n||%s -------> C1:%i --- C2:%i --- C3:%i\n |", studentList[next], markI[next], markII[next], markIII[next]);
  150.         }
  151.     printf("Is all the DATA correct?"), scanf("%s", &ask);
  152.     switch (ask){
  153.         case 'y':
  154.             menushow(studentList, markI, markII, markIII, numStd, code);
  155.             break;
  156.         case 'Y':
  157.             menushow(studentList, markI, markII, markIII, numStd, code);
  158.             break;
  159.         case 'n':
  160.             markcorrection(studentList, markI, markII, markIII, numStd, code);
  161.             break;
  162.         case 'N':
  163.             markcorrection(studentList, markI, markII, markIII, numStd, code);
  164.             break;
  165.         default:
  166.             printf("INVALID INPUT");
  167.             marksask(studentList, markI, markII, markIII, numStd, code);
  168.     }
  169. }
  170. void setToZero(int markI[], int markII[], int markIII[])
  171. {
  172.     int next;
  173.     for(next = 0; next < 75; next++)
  174.     {
  175.         markI[next] = 0;
  176.         markII[next] = 0;
  177.         markIII[next] = 0;
  178.     }
  179. }
  180. void bufferclr(void)
  181. {
  182.      while (getchar() != '\n'){
  183.         ;
  184.     }
  185. }
  186. modesvr(char code[], char studentList[][25], int markI[], int markII[], int markIII[], int numStd)
  187. {
  188.     char check[5], letter;
  189.     printf("Enter your PIN: "), scanf("%c", &check); bufferclr();
  190.     if (strcmp(check, code) == 0){
  191.         printf(" A - change pin\n");
  192.         printf(" B - change mark\n");
  193.         printf(" C - add student\n");
  194.         printf(" D - correct student name\n");
  195.         scanf("%c", &letter);
  196.         switch(letter){
  197.             case 'A':
  198.                 printf(" ------------ ");
  199.                 printf(" A - change pin\n");
  200.                 pinswap(code, studentList, markI, markII, markIII, numStd);
  201.                 break;
  202.             case 'B':
  203.                 printf(" ------------ ");
  204.                 printf(" B - change mark\n");
  205.                 changemark(studentList, markI, markII, markIII, numStd, code);
  206.                 break;
  207.             case 'C':
  208.                 printf(" ------------ ");
  209.                 printf(" C - add student\n");
  210.                 studentadd(studentList, markI, markII, markIII, numStd, code);
  211.                 break;
  212.             case 'D':
  213.                 printf(" ------------ ");
  214.                 printf(" D - correct student name\n");
  215.                 changename(studentList, markI, markII, markIII, numStd, code);
  216.                 break;
  217.         }
  218.     } else {
  219.         printf("INVALID PIN\n"); modesvr(code, studentList, markI, markII, markIII, numStd);
  220.     }
  221. }
  222. void pinswap(char code[], char studentList[][25], int markI[], int markII[], int markIII[], int numStd)
  223. {
  224.     char newcode[5]="0000";
  225.     printf("\n What's the new CODE: "); scanf("%s", newcode); bufferclr();
  226.     if(strcmp(code, newcode)){
  227.     printf("\n CODE changed to: %s.", code);
  228.     }
  229. }
  230. void changemark(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
  231. {
  232.     int std, next, mk;
  233.     marktable(studentList, markI, markII, markIII, numStd, code);
  234.     printf(" ------------------------------------------- ");
  235.     printf("\nWhat student's mark do you want to change? "), scanf("%s", &std);
  236.     for(next=0; next<numStd; next++){
  237.         if(next = 74){      /*compare std to studentList[next] ?*/
  238.             printf("What course?"), scanf("%i", &mk);
  239.             switch(mk){
  240.                 case 1:
  241.                     searchstd(studentList, markI, markII, markIII, numStd, code);
  242.                 case 2:
  243.                     searchstd(studentList, markI, markII, markIII, numStd, code);
  244.                 case 3:
  245.                     searchstd(studentList, markI, markII, markIII, numStd, code);
  246.                 default:
  247.                     changemark(studentList, markI, markII, markIII, numStd, code);
  248.             }
  249.         }
  250.     }
  251. }
  252. void studentadd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
  253. {
  254.     marktable(studentList, markI, markII, markIII, numStd, code);
  255.     int emptybox = 0, next;
  256.     char newstd;
  257.     printf(" \n------------------------------------------- ");
  258.     printf("\nWhat is the name of the student you want to add? "), scanf("%c", &newstd);
  259.     if (numStd < 75){
  260.         for(next=0; next<=numStd; next++){
  261.             if(studentList[next][0] == '\0'){
  262.             studentList[next][25] = newstd;
  263.             }
  264.             else {
  265.                 printf("\nSOMETHING'S WRONG");
  266.                 modesvr(code, studentList, markI, markII, markIII, numStd);
  267.                 break;
  268.             }
  269.         }
  270.        
  271.     } else {
  272.         printf("\nTHE STUDENT LIST IS FULL");
  273.         modesvr(code, studentList, markI, markII, markIII, numStd);
  274.     }
  275. }
  276. void changename(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
  277. {
  278.     marktable(studentList, markI, markII, markIII, numStd, code);
  279.     printf(" ------------------------------------------- ");
  280.     printf("\nWhat student name do you want to change?"),  scanf("%s");
  281.     swapname(studentList, markI, markII, markIII, numStd, code);
  282. }
  283. void thefinale()
  284. {
  285.     char boot;
  286.     printf("\n Later..."), printf("\nClosing program...");
  287.     printf("\n Press X to start the program"), scanf("%s", &boot);
  288.     if(boot=='x' || boot=='X'){
  289.         main();
  290.     } else{
  291.         printf("PROGRAM CLOSED");
  292.     }
  293.    
  294. }
  295. void searchstd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
  296. {
  297.     char std; int next, change;
  298.     printf("What is the name of the student?"), scanf("%s", &std);
  299.  
  300. }
  301. void swapname(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
  302. {
  303.     char stdchoose, std; int next; char change;
  304.     /*printf("What is the name of the student?"), scanf("%c", &stdchoose);
  305.     for(next=0;next<numStd;next++){
  306.         if(studentList[next] == stdchoose){
  307.             printf("What is the correct name? "), scanf("%c", &change);
  308.                 studentList[next][25] = change;
  309.         } else {
  310.             printf("STUDENT DOES NOT EXIST\n\n");
  311.             modesvr(code, studentList, markI, markII, markIII, numStd);
  312.             break;
  313.         }
  314.     }*/
  315. }
  316. void markcorrection(char studentList[][25],  int markI[], int markII[], int markIII[], int numStd, char code[])
  317. {
  318.     int std, course, newmark;
  319.     printf("What's wrong? Enter student number: "), scanf("%i", &std);
  320.     printf("Enter the student coursework you want to change: "), scanf("%i", &course);
  321.     printf("Enter the mark you want for this student %s:  ", studentList[std]), scanf("%i", &newmark);
  322.     switch(course){
  323.         case 1:
  324.             markI[std] = newmark;
  325.             marksask(studentList, markI, markII, markIII, numStd, code);
  326.             break;
  327.         case 2:
  328.             markII[std] = newmark;
  329.             marksask(studentList, markI, markII, markIII, numStd, code);
  330.             break;
  331.         case 3:
  332.             markIII[std] = newmark;
  333.             marksask(studentList, markI, markII, markIII, numStd, code);
  334.             break;
  335.         default:
  336.             printf("INVALID INPUT");
  337.             markcorrection(studentList, markI, markII, markIII, numStd, code);
  338.             break;
  339.     }  
  340. }
  341. void showstd(char studentList[][25],  int markI[], int markII[], int markIII[], int numStd, char code[])
  342. {
  343.     int select, next, final;
  344.     printf("What student do you need to view....? Enter it's number [from 0 ----> %i] ", numStd);
  345.     scanf("%i", &select);
  346.     printf("\n||------------------------------------- |");
  347.     printf("\n||%s -------> C1:%i --- C2:%i --- C3:%i\n |", studentList[select], markI[select], markII[select], markIII[select]);
  348.     final = ((markI[select]*0.2)+ (markII[select]*0.3) + (markIII[select]*0.5));
  349.     printf("final grade of %s is...: %i", studentList[select], final);
  350.     scanf("%c");
  351.     menushow(studentList, markI, markII, markIII, numStd, code);
  352. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement