Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* PROGRAMMING ASSIGNMENT*/
- #include <stdio.h>
- #include <string.h>
- int programIntro(int moduleStd);
- char databaseStd[75][30];
- int markDb(int moduleStd);
- int markOne[76], markTwo[76], markThree[76];
- int markDb(int moduleStd);
- int modeSvr();
- int pinSwap();
- int digit = 1111;
- int main(){
- int moduleStd;
- moduleStd = programIntro(moduleStd);
- menuStarter(moduleStd);
- return 0;
- }
- int programIntro(int moduleStd){
- int nextStd, countStd = 1;
- printf("Please Enter The Number Of Students, Lecturer: ");
- scanf("%i", &moduleStd);
- getchar();
- for (nextStd = 0; nextStd < moduleStd; nextStd++){
- printf("\n Enter the name of student number %i: ", countStd);
- scanf("%[^\n]", &databaseStd[nextStd]);
- getchar();
- countStd++;
- }
- return moduleStd;
- }
- menuStarter(moduleStd){
- int numMn;
- 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");
- scanf("%d", &numMn);
- switch(numMn)
- {
- case 1 :
- printf("Accessing Enter Marks...... \n");
- printf("---------------------------------------------------------------\n\n");
- printf("ENTER MARKS \n");
- printf("//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n");
- markDb(moduleStd);
- break;
- case 2 :
- printf("Accessing Display A Particular Student's Marks...\n");
- printf("---------------------------------------------------------------\n\n");
- printf("DISPLAY A PARTICULAR STUDENT'S MARKS \n");
- printf("//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n");
- break;
- case 3 :
- printf("Accessing Supervisor Mode... \n");
- printf("---------------------------------------------------------------\n\n");
- printf("SUPERVISOR MODE \n");
- printf("//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n");
- modeSvr();
- break;
- case 4 :
- printf("\n\nSaving Data and other things...\n");
- printf("---------------------------------------------------------------\n\n");
- theFinale();
- break;
- default:
- sleep(1), printf("\nProcessing your input... \n");
- menuStarterErr();
- }
- return 0;
- }
- markDb(moduleStd){
- int coursemark, nextMks, tag = 1;
- printf("What coursework do you want to enter marks for? \n");
- scanf("%i", &coursemark);
- printf("------------------------------------------------ \n");
- switch (coursemark){
- case 1:
- if (tag == 1){
- for (nextMks = 0; nextMks < moduleStd; nextMks++){
- printf("Enter mark for %s: ", databaseStd[nextMks]);
- scanf("%i", &markOne[nextMks]);
- }
- tag = 0, markOne[76] = tag;
- markAsk();
- break;
- } else {
- case 0:
- printf("You can't add any more marks since you already added them \n");
- printf("----------------------------------------------------------");
- markDb(moduleStd);
- }
- case 2 :
- if ( tag == 1){
- for (nextMks = 0; nextMks < moduleStd; nextMks++){
- printf("Enter mark for %s: ", databaseStd[nextMks]);
- scanf("%i", &markTwo[nextMks]);
- }
- tag = 0, markTwo[76] = tag;
- markAsk();
- break;
- } else {
- printf("You can't add any more marks since you already added them \n");
- printf("----------------------------------------------------------");
- markDb(moduleStd);
- }
- case 3 :
- if (tag == 1){
- for (nextMks = 0; nextMks < moduleStd; nextMks++){
- printf("Enter mark for %s: ", databaseStd[nextMks]);
- scanf("%i", &markOne[nextMks]);
- }
- tag = 0, markThree[76] = tag;
- markAsk();
- break;
- } else {
- printf("You can't add any more marks since you already added them \n");
- printf("----------------------------------------------------------");
- markDb(moduleStd);
- }
- default: printf("This is an invalid input, please enter number 1, 2 or 3 \n");
- markDb(moduleStd);
- }
- }
- markAsk(int moduleStd){
- char verify;
- printf("Do you want to enter of anymore courseworks? ");
- scanf("%s", &verify);
- switch (verify){
- case 'Y' :
- markDb(moduleStd);
- case 'y' :
- markDb(moduleStd);
- case 'N' :
- tableStd(moduleStd);
- case 'n' :
- tableStd(moduleStd);
- default : printf("Invalid input");
- markAsk(moduleStd);
- }
- }
- tableStd(int moduleStd, char database[][30], int markOne[], int markTwo[], int markThree[]){
- int nextMks;
- printf("Here is a list of the marks that you entered for each students");
- printf("\n======================================================= \n");
- printf("\n|| Student Names || C1 || C2 || C3 ||\n");
- printf("\n=======================================================\n");
- printf("%d\n", moduleStd);
- for (nextMks = 0; nextMks < moduleStd; nextMks++){
- printf("|| %s || %i || %i || %i ||\n", databaseStd[nextMks][nextMks], markOne[nextMks], markTwo[nextMks], markThree[nextMks]);
- printf("=======================================================\n");
- }
- }
- void bufferclr(void){
- while (getchar() != '\n')
- {
- ;
- }
- }
- int menuStarterErr(){
- printf("Invalid Input... Terminating Program... Loading Menu...");
- menuStarter();
- }
- int theFinale(){
- char reMn;
- printf(" 5"), sleep(1), printf(" 4"), sleep(1), printf(" 3"), sleep(1), printf(" 2");
- sleep(1), printf(" 1\n");
- printf("//=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=/=//\n\n");
- printf("Closing program... See you soon!\n\n");
- printf("The program has been closed; press X if you want to initiate it again... \n");
- /* Make sure it can be x or X nothing else */
- scanf("%c ", &reMn);
- if (reMn == 'X' || reMn == 'x'){
- menuStarter();
- }
- else {
- printf("Entered the wrong input, the program will reStart in 3 seconds");
- sleep(3);
- }
- return 0;
- }
- modeSvr(){
- char optionSvr;
- printf(" A. CHANGE THE PIN \n");
- printf(" B. CHANGE A STUDENTS MARK\n");
- printf(" C. ADD STUDENT\n");
- printf(" D. CHANGE STUDENT NAME\n");
- scanf("%c", &optionSvr);
- switch (optionSvr){
- case 'A':
- pinSwap();
- break;
- case 'a':
- pinSwap();
- break;
- case 'B':
- markSwap();
- break;
- case 'b':
- markSwap();
- break;
- case 'C':
- studentPlus();
- break;
- case 'c':
- studentPlus();
- break;
- case 'D':
- studentModify();
- break;
- case 'd':
- studentModify();
- break;
- default:
- printf("--------\n");
- modeSvr();
- break;
- }
- return 0;
- }
- pinSwap(){
- int swapper, chk;
- int count = 0;
- printf("\nEnter your pin code:");
- scanf("%c", &chk);
- if (chk == digit){
- printf("What do you want to change your Code to? \n");
- scanf("%lld", &swapper);
- while(swapper != 0)
- {
- swapper /= 10;
- ++count;
- }
- if (count == 4){
- digit = swapper;
- printf("Code change successful!");
- modeSvr();
- }
- }
- }
- markSwap(){
- return 0;
- }
- studentPlus(){
- return 0;
- }
- studentModify(){
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement