Advertisement
Guest User

ForTomToHelpANoobLikePhilip

a guest
Nov 19th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.63 KB | None | 0 0
  1. /* PROGRAMMING ASSIGNMENT*/
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. int programIntro(int moduleStd);
  7. char databaseStd[75][30];
  8. int markDb(int moduleStd);
  9. int markOne[76], markTwo[76], markThree[76];
  10. int markDb(int moduleStd);
  11. int modeSvr();
  12. int pinSwap();
  13. int digit = 1111;
  14.  
  15.  
  16. int main(){
  17. int moduleStd;
  18. moduleStd = programIntro(moduleStd);
  19. menuStarter(moduleStd);
  20. return 0;
  21. }
  22. int programIntro(int moduleStd){
  23. int nextStd, countStd = 1;
  24. printf("Please Enter The Number Of Students, Lecturer: ");
  25. scanf("%i", &moduleStd);
  26. getchar();
  27. for (nextStd = 0; nextStd < moduleStd; nextStd++){
  28. printf("\n Enter the name of student number %i: ", countStd);
  29. scanf("%[^\n]", &databaseStd[nextStd]);
  30. getchar();
  31. countStd++;
  32. }
  33. return moduleStd;
  34. }
  35.  
  36. menuStarter(moduleStd){
  37. int numMn;
  38. printf("\n\n MAIN MENU \n"
  39. "//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n"
  40. "// //\n"
  41. "// 1 Enter marks //\n"
  42. "// //\n"
  43. "// 2 Display A Particular Student's Marks //\n"
  44. "// //\n"
  45. "// 3 Supervisor Mode //\n"
  46. "// //\n"
  47. "// 4 Exit Program //\n"
  48. "// //\n"
  49. "//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n\n");
  50. scanf("%d", &numMn);
  51. switch(numMn)
  52. {
  53. case 1 :
  54. printf("Accessing Enter Marks...... \n");
  55. printf("---------------------------------------------------------------\n\n");
  56. printf("ENTER MARKS \n");
  57. printf("//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n");
  58. markDb(moduleStd);
  59. break;
  60. case 2 :
  61. printf("Accessing Display A Particular Student's Marks...\n");
  62. printf("---------------------------------------------------------------\n\n");
  63. printf("DISPLAY A PARTICULAR STUDENT'S MARKS \n");
  64. printf("//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n");
  65.  
  66. break;
  67. case 3 :
  68. printf("Accessing Supervisor Mode... \n");
  69. printf("---------------------------------------------------------------\n\n");
  70. printf("SUPERVISOR MODE \n");
  71. printf("//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n");
  72. modeSvr();
  73. break;
  74. case 4 :
  75. printf("\n\nSaving Data and other things...\n");
  76. printf("---------------------------------------------------------------\n\n");
  77. theFinale();
  78. break;
  79. default:
  80. sleep(1), printf("\nProcessing your input... \n");
  81. menuStarterErr();
  82. }
  83. return 0;
  84. }
  85.  
  86. markDb(moduleStd){
  87. int coursemark, nextMks, tag = 1;
  88. printf("What coursework do you want to enter marks for? \n");
  89. scanf("%i", &coursemark);
  90. printf("------------------------------------------------ \n");
  91. switch (coursemark){
  92. case 1:
  93. if (tag == 1){
  94. for (nextMks = 0; nextMks < moduleStd; nextMks++){
  95. printf("Enter mark for %s: ", databaseStd[nextMks]);
  96. scanf("%i", &markOne[nextMks]);
  97. }
  98. tag = 0, markOne[76] = tag;
  99. markAsk();
  100. break;
  101. } else {
  102. case 0:
  103. printf("You can't add any more marks since you already added them \n");
  104. printf("----------------------------------------------------------");
  105. markDb(moduleStd);
  106. }
  107. case 2 :
  108. if ( tag == 1){
  109. for (nextMks = 0; nextMks < moduleStd; nextMks++){
  110. printf("Enter mark for %s: ", databaseStd[nextMks]);
  111. scanf("%i", &markTwo[nextMks]);
  112. }
  113. tag = 0, markTwo[76] = tag;
  114. markAsk();
  115. break;
  116. } else {
  117. printf("You can't add any more marks since you already added them \n");
  118. printf("----------------------------------------------------------");
  119. markDb(moduleStd);
  120. }
  121. case 3 :
  122. if (tag == 1){
  123. for (nextMks = 0; nextMks < moduleStd; nextMks++){
  124. printf("Enter mark for %s: ", databaseStd[nextMks]);
  125. scanf("%i", &markOne[nextMks]);
  126. }
  127. tag = 0, markThree[76] = tag;
  128. markAsk();
  129. break;
  130. } else {
  131. printf("You can't add any more marks since you already added them \n");
  132. printf("----------------------------------------------------------");
  133. markDb(moduleStd);
  134. }
  135. default: printf("This is an invalid input, please enter number 1, 2 or 3 \n");
  136. markDb(moduleStd);
  137. }
  138. }
  139. markAsk(int moduleStd){
  140. char verify;
  141. printf("Do you want to enter of anymore courseworks? ");
  142. scanf("%s", &verify);
  143. switch (verify){
  144. case 'Y' :
  145. markDb(moduleStd);
  146. case 'y' :
  147. markDb(moduleStd);
  148. case 'N' :
  149. tableStd(moduleStd);
  150.  
  151. case 'n' :
  152. tableStd(moduleStd);
  153. default : printf("Invalid input");
  154. markAsk(moduleStd);
  155. }
  156. }
  157.  
  158. tableStd(int moduleStd){
  159. int nextMks;
  160. printf("Here is a list of the marks that you entered for each students");
  161. printf("\n======================================================= \n");
  162. printf("\n|| Student Names || C1 || C2 || C3 ||\n");
  163. printf("\n=======================================================\n");
  164. printf("%d\n", moduleStd);
  165. for (nextMks = 0; nextMks < moduleStd; nextMks++){
  166.  
  167. printf("|| %s || %i || %i || %i ||\n", databaseStd[nextMks], markOne[nextMks], markTwo[nextMks], markThree[nextMks]);
  168. printf("=======================================================\n");
  169. }
  170. }
  171. void bufferclr(void){
  172. while (getchar() != '\n')
  173. {
  174. ;
  175. }
  176.  
  177. }
  178. int menuStarterErr(){
  179. printf("Invalid Input... Terminating Program... Loading Menu...");
  180. menuStarter();
  181. }
  182. int theFinale(){
  183. char reMn;
  184.  
  185. printf(" 5"), sleep(1), printf(" 4"), sleep(1), printf(" 3"), sleep(1), printf(" 2");
  186. sleep(1), printf(" 1\n");
  187. printf("//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n\n");
  188. printf("Closing program... See you soon!\n\n");
  189. printf("The program has been closed; press X if you want to initiate it again... \n");
  190. /* Make sure it can be x or X nothing else */
  191. scanf("%c ", &reMn);
  192. if (reMn == 'X' || reMn == 'x'){
  193. menuStarter();
  194. }
  195. else {
  196. printf("Entered the wrong input, the program will reStart in 3 seconds");
  197. sleep(3);
  198. }
  199. return 0;
  200. }
  201.  
  202. modeSvr(){
  203. char optionSvr;
  204. printf(" A. CHANGE THE PIN \n");
  205. printf(" B. CHANGE A STUDENTS MARK\n");
  206. printf(" C. ADD STUDENT\n");
  207. printf(" D. CHANGE STUDENT NAME\n");
  208. scanf("%c", &optionSvr);
  209.  
  210. switch (optionSvr){
  211. case 'A':
  212. pinSwap();
  213. break;
  214. case 'a':
  215. pinSwap();
  216. break;
  217. case 'B':
  218. markSwap();
  219. break;
  220. case 'b':
  221. markSwap();
  222. break;
  223. case 'C':
  224. studentPlus();
  225. break;
  226. case 'c':
  227. studentPlus();
  228. break;
  229. case 'D':
  230. studentModify();
  231. break;
  232. case 'd':
  233. studentModify();
  234. break;
  235. default:
  236. printf("--------\n");
  237. modeSvr();
  238. break;
  239. }
  240. return 0;
  241. }
  242.  
  243. pinSwap(){
  244. int swapper, chk;
  245. int count = 0;
  246.  
  247. printf("\nEnter your pin code:");
  248. scanf("%c", &chk);
  249.  
  250. if (chk == digit){
  251. printf("What do you want to change your Code to? \n");
  252. scanf("%lld", &swapper);
  253. while(swapper != 0)
  254. {
  255. swapper /= 10;
  256. ++count;
  257. }
  258. if (count == 4){
  259. digit = swapper;
  260. printf("Code change successful!");
  261. modeSvr();
  262. }
  263. }
  264. }
  265.  
  266. markSwap(){
  267.  
  268. return 0;
  269. }
  270. studentPlus(){
  271.  
  272. return 0;
  273. }
  274. studentModify(){
  275.  
  276. return 0;
  277. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement