Advertisement
Guest User

forjan3

a guest
Nov 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.01 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[4]);
  7. void menushow(char studentList[75][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
  8. void bufferclr();
  9. void marksask(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
  10. void marktable(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
  11. void setToZero(int markI[], int markII[], int markIII[]);
  12. void modeSvr(char code[4], char studentList[75][25], int markI[], int markII[], int markIII[], int numStd);
  13. void pinswap(char code[4], 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[4]);
  15. void studentadd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
  16. void changename(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
  17. void searchstd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
  18. void swapname(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
  19. void thefinale();
  20. void markcorrection(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
  21. void showstd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
  22. void main()
  23. {
  24. char studentList[75][25], code[]="6969";
  25. int numStd, markI[75], markII[75], markIII[75];
  26. int option;
  27. setToZero(markI, markII, markIII);
  28. numStd = introduction(studentList, numStd);
  29. while(option != 4)
  30. {
  31. option = menushow(studentList, markI, markII, markIII, numStd, code);
  32. }
  33.  
  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[4])
  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[4])
  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("%c", &newcode); bufferclr();
  226. if(strcmp(code, newcode)){
  227. printf("\n CODE changed."), modesvr(code, studentList, markI, markII, markIII, numStd);
  228. } else {
  229. printf("INVALID CODE");
  230. }
  231. }
  232. void changemark(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
  233. {
  234. int std, next, mk;
  235. marktable(studentList, markI, markII, markIII, numStd, code);
  236. printf(" ------------------------------------------- ");
  237. printf("\nWhat student's mark do you want to change? "), scanf("%s", &std);
  238. for(next=0; next<numStd; next++){
  239. if(next = 74){ /*compare std to studentList[next] ?*/
  240. printf("What course?"), scanf("%i", &mk);
  241. switch(mk){
  242. case 1:
  243. searchstd(studentList, markI, markII, markIII, numStd, code);
  244. case 2:
  245. searchstd(studentList, markI, markII, markIII, numStd, code);
  246. case 3:
  247. searchstd(studentList, markI, markII, markIII, numStd, code);
  248. default:
  249. changemark(studentList, markI, markII, markIII, numStd, code);
  250. }
  251. }
  252. }
  253. }
  254. void studentadd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
  255. {
  256. marktable(studentList, markI, markII, markIII, numStd, code);
  257. int emptybox = 0, next;
  258. char newstd;
  259. printf(" \n------------------------------------------- ");
  260. printf("\nWhat is the name of the student you want to add? "), scanf("%c", &newstd);
  261. if (numStd < 75){
  262. for(next=0; next<=numStd; next++){
  263. if(studentList[next] == emptybox){
  264. studentList[next][25] = newstd;
  265. }
  266. else {
  267. printf("\nSOMETHING'S WRONG");
  268. modesvr(code, studentList, markI, markII, markIII, numStd);
  269. break;
  270. }
  271. }
  272.  
  273. } else {
  274. printf("\nTHE STUDENT LIST IS FULL");
  275. modesvr(code, studentList, markI, markII, markIII, numStd);
  276. }
  277. }
  278. void changename(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
  279. {
  280. marktable(studentList, markI, markII, markIII, numStd, code);
  281. printf(" ------------------------------------------- ");
  282. printf("\nWhat student name do you want to change?"), scanf("%s");
  283. swapname(studentList, markI, markII, markIII, numStd, code);
  284. }
  285. void thefinale()
  286. {
  287. char boot;
  288. printf("\n Later..."), printf("\nClosing program...");
  289. printf("\n Press X to start the program"), scanf("%s", &boot);
  290. if(boot=='x' || boot=='X'){
  291. main();
  292. } else{
  293. printf("PROGRAM CLOSED");
  294. }
  295.  
  296. }
  297. void searchstd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
  298. {
  299. char std; int next, change;
  300. printf("What is the name of the student?"), scanf("%s", &std);
  301.  
  302. }
  303. void swapname(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
  304. {
  305. char stdchoose, std; int next; char change;
  306. printf("What is the name of the student?"), scanf("%c", &stdchoose);
  307. for(next=0;next<numStd;next++){
  308. if(studentList[next] == stdchoose){
  309. printf("What is the correct name? "), scanf("%c", &change);
  310. studentList[next][25] = change;
  311. } else {
  312. printf("STUDENT DOES NOT EXIST\n\n");
  313. modesvr(code, studentList, markI, markII, markIII, numStd);
  314. break;
  315. }
  316. }
  317. }
  318. void markcorrection(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
  319. {
  320. int std, course, newmark;
  321. printf("What's wrong? Enter student number: "), scanf("%i", &std);
  322. printf("Enter the student coursework you want to change: "), scanf("%i", &course);
  323. printf("Enter the mark you want for this student %s: ", studentList[std]), scanf("%i", &newmark);
  324. switch(course){
  325. case 1:
  326. markI[std] = newmark;
  327. marksask(studentList, markI, markII, markIII, numStd, code);
  328. break;
  329. case 2:
  330. markII[std] = newmark;
  331. marksask(studentList, markI, markII, markIII, numStd, code);
  332. break;
  333. case 3:
  334. markIII[std] = newmark;
  335. marksask(studentList, markI, markII, markIII, numStd, code);
  336. break;
  337. default:
  338. printf("INVALID INPUT");
  339. markcorrection(studentList, markI, markII, markIII, numStd, code);
  340. break;
  341. }
  342. }
  343. void showstd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]){
  344. int select, next, final;
  345. printf("What student do you need to view....? Enter it's number [from 0 ----> %i] ", numStd);
  346. scanf("%i", &select);
  347. printf("\n||------------------------------------- |");
  348. printf("\n||%s -------> C1:%i --- C2:%i --- C3:%i\n |", studentList[select], markI[select], markII[select], markIII[select]);
  349. final = ((markI[select]*0.2)+ (markII[select]*0.3) + (markIII[select]*0.5));
  350. printf("final grade of %s is...: %i", studentList[select], final);
  351. scanf("%c");
  352. menushow(studentList, markI, markII, markIII, numStd, code);
  353. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement