Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- int introduction(char studentList[75][25], int numStd);
- void marks(char studentList[75][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
- void menushow(char studentList[75][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
- void bufferclr();
- void marksask(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
- void marktable(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
- void setToZero(int markI[], int markII[], int markIII[]);
- void modeSvr(char code[4], char studentList[75][25], int markI[], int markII[], int markIII[], int numStd);
- void pinswap(char code[4], char studentList[][25], int markI[], int markII[], int markIII[], int numStd);
- void changemark(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
- void studentadd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
- void changename(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
- void searchstd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
- void swapname(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
- void thefinale();
- void markcorrection(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
- void showstd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]);
- void main()
- {
- char studentList[75][25], code[]="6969";
- int numStd, markI[75], markII[75], markIII[75];
- int option;
- setToZero(markI, markII, markIII);
- numStd = introduction(studentList, numStd);
- while(option != 4)
- {
- option = menushow(studentList, markI, markII, markIII, numStd, code);
- }
- }
- int introduction(char studentList[][25], int numStd)
- {
- int next;
- printf("Enter number of students: ");
- scanf("%i", &numStd);
- bufferclr();
- /*Store the Students*/
- for(next=0; next<numStd; next++){
- printf("Enter the student name of No.%i: \n", next);
- scanf("%24s", &studentList[next]);
- bufferclr();
- }
- return numStd;
- }
- int menushow(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
- {
- int menunum;
- printf("\n\n MAIN MENU \n"
- "//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n"
- "// //\n"
- "// 1 Enter marks //\n"
- "// //\n"
- "// 2 Display A Particular Student's Marks //\n"
- "// //\n"
- "// 3 Supervisor Mode //\n"
- "// //\n"
- "// 4 Exit Program //\n"
- "// //\n"
- "//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n\n");
- printf(" Where do you want to go? Type the number: ");
- scanf("%i", &menunum); bufferclr();
- switch(menunum){
- case 1:
- printf("// 1 Enter marks \\ \n");
- marks(studentList, markI, markII, markIII, numStd, code);
- break;
- case 2:
- printf("// 2 Display A Particular Student's Marks \\ \n");
- showstd(studentList, markI, markII, markIII, numStd, code);
- break;
- case 3:
- printf("// 3 Supervisor Mode \\ \n");
- modesvr(code, markI, markII, markIII, numStd);
- break;
- case 4:
- printf("// 4 Exit Program \\ \n");
- thefinale();
- break;
- }
- return menunum;
- }
- void marks(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
- {
- int coursemark, next, tag = 1;
- printf("What coursework do you want to enter marks for? "), scanf("%i", &coursemark); bufferclr();
- printf("------------------------------------------------ \n");
- switch(coursemark){
- case 1:
- for(next=0; next<numStd; next++){
- printf("Student: %s :", studentList[next]);
- scanf("%i", &markI[next]); bufferclr();
- }
- marksask(studentList, markI, markII, markIII, numStd, code);
- break;
- case 2:
- for(next=0; next<numStd; next++){
- printf("Student: %s :", studentList[next]);
- scanf("%i", &markII[next]); bufferclr();
- }
- marksask(studentList, markI, markII, markIII, numStd, code);
- break;
- case 3:
- for(next=0; next<numStd; next++){
- printf("Student: %s :", studentList[next]);
- scanf("%i", &markIII[next]); bufferclr();
- }
- marksask(studentList, markI, markII, markIII, numStd, code);
- break;
- default:
- printf("INVALID INPUT");
- }
- }
- void marksask(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4])
- {
- char ask;
- printf("Enter marks for another coursework Y or N:"), scanf("%s", &ask);
- switch (ask){
- case 'y':
- marktable(studentList, markI, markII, markIII, numStd, code);
- markcorrection(studentList, markI, markII, markIII, numStd, code);
- break;
- case 'Y':
- marktable(studentList, markI, markII, markIII, numStd, code);
- markcorrection(studentList, markI, markII, markIII, numStd, code);
- break;
- case 'n':
- marktable(studentList, markI, markII, markIII, numStd, code);
- break;
- case 'N':
- marktable(studentList, markI, markII, markIII, numStd, code);
- break;
- default:
- printf("INVALID INPUT");
- marksask(studentList, markI, markII, markIII, numStd, code);
- }
- }
- void marktable(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4])
- {
- int next; char ask;
- /* Display the students */
- for(next=0; next<numStd; next++){
- printf("\n||------------------------------------- |");
- printf("\n||%s -------> C1:%i --- C2:%i --- C3:%i\n |", studentList[next], markI[next], markII[next], markIII[next]);
- }
- printf("Is all the DATA correct?"), scanf("%s", &ask);
- switch (ask){
- case 'y':
- menushow(studentList, markI, markII, markIII, numStd, code);
- break;
- case 'Y':
- menushow(studentList, markI, markII, markIII, numStd, code);
- break;
- case 'n':
- markcorrection(studentList, markI, markII, markIII, numStd, code);
- break;
- case 'N':
- markcorrection(studentList, markI, markII, markIII, numStd, code);
- break;
- default:
- printf("INVALID INPUT");
- marksask(studentList, markI, markII, markIII, numStd, code);
- }
- }
- void setToZero(int markI[], int markII[], int markIII[])
- {
- int next;
- for(next = 0; next < 75; next++)
- {
- markI[next] = 0;
- markII[next] = 0;
- markIII[next] = 0;
- }
- }
- void bufferclr(void)
- {
- while (getchar() != '\n'){
- ;
- }
- }
- modesvr(char code[], char studentList[][25], int markI[], int markII[], int markIII[], int numStd)
- {
- char check[5], letter;
- printf("Enter your PIN: "), scanf("%c", &check); bufferclr();
- if (strcmp(check, code) == 0){
- printf(" A - change pin\n");
- printf(" B - change mark\n");
- printf(" C - add student\n");
- printf(" D - correct student name\n");
- scanf("%c", &letter);
- switch(letter){
- case 'A':
- printf(" ------------ ");
- printf(" A - change pin\n");
- pinswap(code, studentList, markI, markII, markIII, numStd);
- break;
- case 'B':
- printf(" ------------ ");
- printf(" B - change mark\n");
- changemark(studentList, markI, markII, markIII, numStd, code);
- break;
- case 'C':
- printf(" ------------ ");
- printf(" C - add student\n");
- studentadd(studentList, markI, markII, markIII, numStd, code);
- break;
- case 'D':
- printf(" ------------ ");
- printf(" D - correct student name\n");
- changename(studentList, markI, markII, markIII, numStd, code);
- break;
- }
- } else {
- printf("INVALID PIN\n"); modesvr(code, studentList, markI, markII, markIII, numStd);
- }
- }
- void pinswap(char code[], char studentList[][25], int markI[], int markII[], int markIII[], int numStd)
- {
- char newcode[5]="0000";
- printf("\n What's the new CODE: "), scanf("%c", &newcode); bufferclr();
- if(strcmp(code, newcode)){
- printf("\n CODE changed."), modesvr(code, studentList, markI, markII, markIII, numStd);
- } else {
- printf("INVALID CODE");
- }
- }
- void changemark(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
- {
- int std, next, mk;
- marktable(studentList, markI, markII, markIII, numStd, code);
- printf(" ------------------------------------------- ");
- printf("\nWhat student's mark do you want to change? "), scanf("%s", &std);
- for(next=0; next<numStd; next++){
- if(next = 74){ /*compare std to studentList[next] ?*/
- printf("What course?"), scanf("%i", &mk);
- switch(mk){
- case 1:
- searchstd(studentList, markI, markII, markIII, numStd, code);
- case 2:
- searchstd(studentList, markI, markII, markIII, numStd, code);
- case 3:
- searchstd(studentList, markI, markII, markIII, numStd, code);
- default:
- changemark(studentList, markI, markII, markIII, numStd, code);
- }
- }
- }
- }
- void studentadd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
- {
- marktable(studentList, markI, markII, markIII, numStd, code);
- int emptybox = 0, next;
- char newstd;
- printf(" \n------------------------------------------- ");
- printf("\nWhat is the name of the student you want to add? "), scanf("%c", &newstd);
- if (numStd < 75){
- for(next=0; next<=numStd; next++){
- if(studentList[next] == emptybox){
- studentList[next][25] = newstd;
- }
- else {
- printf("\nSOMETHING'S WRONG");
- modesvr(code, studentList, markI, markII, markIII, numStd);
- break;
- }
- }
- } else {
- printf("\nTHE STUDENT LIST IS FULL");
- modesvr(code, studentList, markI, markII, markIII, numStd);
- }
- }
- void changename(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
- {
- marktable(studentList, markI, markII, markIII, numStd, code);
- printf(" ------------------------------------------- ");
- printf("\nWhat student name do you want to change?"), scanf("%s");
- swapname(studentList, markI, markII, markIII, numStd, code);
- }
- void thefinale()
- {
- char boot;
- printf("\n Later..."), printf("\nClosing program...");
- printf("\n Press X to start the program"), scanf("%s", &boot);
- if(boot=='x' || boot=='X'){
- main();
- } else{
- printf("PROGRAM CLOSED");
- }
- }
- void searchstd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
- {
- char std; int next, change;
- printf("What is the name of the student?"), scanf("%s", &std);
- }
- void swapname(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
- {
- char stdchoose, std; int next; char change;
- printf("What is the name of the student?"), scanf("%c", &stdchoose);
- for(next=0;next<numStd;next++){
- if(studentList[next] == stdchoose){
- printf("What is the correct name? "), scanf("%c", &change);
- studentList[next][25] = change;
- } else {
- printf("STUDENT DOES NOT EXIST\n\n");
- modesvr(code, studentList, markI, markII, markIII, numStd);
- break;
- }
- }
- }
- void markcorrection(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[])
- {
- int std, course, newmark;
- printf("What's wrong? Enter student number: "), scanf("%i", &std);
- printf("Enter the student coursework you want to change: "), scanf("%i", &course);
- printf("Enter the mark you want for this student %s: ", studentList[std]), scanf("%i", &newmark);
- switch(course){
- case 1:
- markI[std] = newmark;
- marksask(studentList, markI, markII, markIII, numStd, code);
- break;
- case 2:
- markII[std] = newmark;
- marksask(studentList, markI, markII, markIII, numStd, code);
- break;
- case 3:
- markIII[std] = newmark;
- marksask(studentList, markI, markII, markIII, numStd, code);
- break;
- default:
- printf("INVALID INPUT");
- markcorrection(studentList, markI, markII, markIII, numStd, code);
- break;
- }
- }
- void showstd(char studentList[][25], int markI[], int markII[], int markIII[], int numStd, char code[4]){
- int select, next, final;
- printf("What student do you need to view....? Enter it's number [from 0 ----> %i] ", numStd);
- scanf("%i", &select);
- printf("\n||------------------------------------- |");
- printf("\n||%s -------> C1:%i --- C2:%i --- C3:%i\n |", studentList[select], markI[select], markII[select], markIII[select]);
- final = ((markI[select]*0.2)+ (markII[select]*0.3) + (markIII[select]*0.5));
- printf("final grade of %s is...: %i", studentList[select], final);
- scanf("%c");
- menushow(studentList, markI, markII, markIII, numStd, code);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement