Advertisement
Guest User

forJanMyBigBro

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