1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 15
int menuM(char n[SIZE][26],double f[SIZE],double q[SIZE],double m[SIZE],double t[SIZE],int id[SIZE]);
int menu2(char n[SIZE][26],double f[SIZE],double q[SIZE],double m[SIZE],double t[SIZE],int id[SIZE]);
int menu3(char n[SIZE][26],double f[SIZE],double q[SIZE],double m[SIZE],double t[SIZE],int id[SIZE]);
void min_max (double a[SIZE], double *min, double *max,double *avg);
void sorter (char n[SIZE][26],double f[SIZE],double q[SIZE],double m[SIZE],double t[SIZE],int id[SIZE]);
int search(int a[SIZE],int b);
int scanner(char n[SIZE][26],double f[SIZE],double q[SIZE],double m[SIZE],double t[SIZE],int id[SIZE]);
void store(char n[SIZE][26],double f[SIZE],double q[SIZE],double m[SIZE],double t[SIZE],int id[SIZE]);
void display(char n[SIZE][26],double f[SIZE],double q[SIZE],double m[SIZE],double t[SIZE],int id[SIZE]);
void optional(char n[SIZE][26],double f[SIZE],double q[SIZE],double m[SIZE],double t[SIZE],int id[SIZE],int choice);
void del(char n[SIZE][26],double f[SIZE],double q[SIZE],double m[SIZE],double t[SIZE],int id[SIZE]);
/*Main Function+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
int main(void) {
char name[SIZE][26];
double quiz[SIZE],final[SIZE],major[SIZE],total[SIZE];
int id[SIZE],ch,a;
scanner(name,final,quiz,major,total,id);
menuM(name,final,quiz,major,total,id);
return (EXIT_SUCCESS);
}
/*Function Defintion++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
int menuM(char n[SIZE][26],double f[SIZE],double q[SIZE],double m[SIZE],double t[SIZE],int id[SIZE]){
scanner(n,f,q,m,t,id);
int var;
system ("cls");
printf("\nMAIN MENU");
printf("\n1. Display the complete students’ records.");
printf("\n2. Student menu");
printf("\n3. Activity Menu (Major/ Final/ Quiz)");
printf("\n4. Add a new student record");
printf("\n5. Delete a student record.");
printf("\n6. Exit");
printf("\nPleses enter your choice: ");
scanf("%d",&var);
switch(var){
case 1: display(n,f,q,m,t,id);
system("pause");
menuM(n,f,q,m,t,id);
break;
case 2: menu2(n,f,q,m,t,id);
break;
case 3: menu3(n,f,q,m,t,id);
break;
case 4: store(n,f,q,m,t,id);
menuM(n,f,q,m,t,id);
break;
case 5: del(n,f,q,m,t,id);
menuM(n,f,q,m,t,id);
break;
case 6: printf("\nThe program will be terminated!!");
return 6;
break;
default: printf("\nThere is no such choice");
menuM(n,f,q,m,t,id);
}}
int menu2(char n[SIZE][26],double f[SIZE],double q[SIZE],double m[SIZE],double t[SIZE],int id[SIZE]){
int ids,pos,var;
system ("cls");
printf("\nPlease enter the student id >");
scanf("%d",ids);
pos=search(id,ids);
if(pos=-1){
printf("\n1.Return to the main menu.");
printf("\n2.Return to the students menu.");
printf("\nPleses enter your choice: ");
scanf("%d",&var);
switch(var)
{
case 1: menuM(n,f,q,m,t,id);
break;
case 2: menu2(n,f,q,m,t,id);
break;
default: printf("\nThere is no such choice");
menu2(n,f,q,m,t,id);
break;}}
else printf("\nRank:%d \nID:%d \nName:%s \nMajor:%.2lf \nQuiz:%.2lf \nFinal:%.2lf \nTotal:%.2lf \n\n",pos+1,id[pos],n[pos][26],m[pos],q[pos],f[pos],t[pos]);
printf("STUDENT MENU");
printf("\n1. Update Student Major Marks.");
printf("\n2. Update Student Final Marks.");
printf("\n3. Update Student Quiz Marks.");
printf("\n4. Return to main menu.");
printf("\nPleses enter your choice:");
scanf("%d",&var);
switch(var){
case 1: printf("\nPlease enter the new major grade >");
scanf("%lf",m[pos]);
menuM(n,f,q,m,t,id);
break;
case 2: printf("\nPlease enter the new final grade >");
scanf("%lf",f[pos]);
menuM(n,f,q,m,t,id);
break;
case 3: printf("\nPlease enter the new qiuz grade >");
scanf("%lf",q[pos]);
menuM(n,f,q,m,t,id);
break;
case 4: menuM(n,f,q,m,t,id);
break;
default: menu2(n,f,q,m,t,id);
break;
}}
int menu3(char n[SIZE][26],double f[SIZE],double q[SIZE],double m[SIZE],double t[SIZE],int id[SIZE]){
int var,i,choice;
double min,max,avg;
system("cls");
printf("\nACTIVITY MENU");
printf("\n1. Major.");
printf("\n2. Final.");
printf("\n3. Quiz.");
printf("\n4. Return to main menu.");
printf("\nPleses enter your choice: ");
scanf("%d",&var);
|