0

It is a grading system, but its not calulating the grades

#include<stdio.h>
#include<conio.h>
#include<string.h>
#define max 2

void Cal_semester_Grade(char studname[][25],int gradeavg[][1],int examAvg[][1]);
void Class_Grade(char studname[][25],char classname[5], int classgrd[][3],int gradeavg[][1], int Maxtestscr[][3],char subjectname[15],int classprectge[][3],int finalClassgrade[][1]);
void Exam_Grade(char studname[][25], int examMarks[][2], int MaxExamTest[][2],int Examperctage[][2],int examAvg[][1],int finalExamgrade[][1],int paperweight[][2]);

//void search_name(char);
void Menu();
char studname[max][25];
int gradeavg[max][1];
int classgrd[max][3];
char classname[15];
char subjectname[15];
int examAvg[max][1];
int paperweight[max][2];
int Maxtestscr[max][3];
int semesteravg[max][1];
int examMarks[max][2];
int MaxExamTest[max][2];
char studsearch[25];
int Examperctage[max][2];
int finalExamgrade[max][1]={
                            {0},
                            {0}
                           };

int finalClassgrade[max][1]={
                            {0}
                            };

int classprectge[max][3];
                      
int find;
int ans;

int main()
{

int choice,i,n,l,c;


Menu();
printf("\nPlease enter choice:\t");
scanf("%d",&choice);

switch (choice)
{
   case 1:

          for( i=0;i<max;i++)
           {
               printf("\n Please enter students name:\t");
               scanf("%s",&studname[i]);
               printf("\n Please enter students class :\t");
               scanf("%s",&classname);
               printf("\n Please enter subject name:\t");
               scanf("%s",&subjectname[i]);

                  for( c=0;c<3;c++)
                    {
                       printf("\n Please enter Class grade %d for:\t",c+1);
                       scanf("%s",&classgrd[i][c]);
                       printf("Please enter Maximum mark for Test %d\t",c+1);
                       scanf("%d",&Maxtestscr[i][c]);
                    }
           }
      Class_Grade(studname,classname,classgrd,gradeavg,Maxtestscr,subjectname,classprectge,finalClassgrade);
     break;

  
   case 2:

         printf("\n Please enter students name:\t");
         scanf("%s",&studsearch);

               for(l=0;l<max;l++)
                  {
       	            if(strcmp(studsearch,studname[l])==NULL)
                      {
                        printf("Sorry Student not found");
                        printf("Class grade has to be available for student");
                        printf("Would you like to enter grades for this student?");
                        scanf("%d",ans);
                    		    if(ans=1)
                    		     {
                                Class_Grade(studname,classname,classgrd,gradeavg,Maxtestscr,subjectname,classprectge,finalClassgrade);
                             }

                        }
                              else
                                  {
                                   //find=l;
              	                       for(n=0;n<2;n++)
                                        {
                                     printf("\n Please enter Exam score for Paper %d:\n",n+1);
                                     scanf("%d",&examMarks[l][n]);
                                     printf("\n Please enter weight of paper %d:\n",n+1);
                                     scanf("%s",&paperweight[l][n]);

                                     printf("\n Please enter Total Marks on Paper %d:\n",n+1);
                                     scanf("%d",&MaxExamTest[l][n]);
                                        }
                          }

            }

       Exam_Grade(studname,examMarks,MaxExamTest,Examperctage,examAvg,finalExamgrade,paperweight);

       break;

     default:
        printf("You have entered an invalid choice");
      }
      getch();
      return 0;
      }


void Menu()
{
printf("**************WELCOME TO MAIN MENU*************");

printf("\n1.Calculate class grade");
printf("\n2.Calculate Exam grade");
printf("\n3.Calculate semester grade");
printf("\n4.Enter Student's Name");
printf("\nmenu");
}


void  Class_Grade(char studname[][25],char classname[5], int classgrd[][3],int gradeavg[][1], int Maxtestscr[][3],char subjectname [15], int classprectge[][3],int finalClassgrade[][1])
{
     for(int a=0;a<max;a++)
     {
         for(int z=0; z<3;z++)
         {
            classprectge[a][z]=(classgrd[a][z]/Maxtestscr[a][z]);
            finalClassgrade[a][z]=finalClassgrade[a][z]+ classprectge[a][z];
         }
     }
        for(int countClgrd=0;countClgrd<max;countClgrd++)
             {
                for(int innercnt=0;innercnt<1;innercnt++)
                 {
                    gradeavg[countClgrd][innercnt]= (finalClassgrade[countClgrd][innercnt])/3;
                 }
             }
         printf("Would you like to calculate exams grades for these students?");
         printf("1: Calculate Grade   2: Exit");
         scanf("%d",&ans);
         		if(ans=1)
                {

                Exam_Grade(studname,examMarks,MaxExamTest,Examperctage,examAvg,finalExamgrade,paperweight);
                }
                else
                {

                         printf("\n%-15s\t%-15s\t%-15s\t%-5s\n","Name","Class","Subject","Average");
                         printf("\n-----------------------------------------------------------------\n");
                              for(int count=0;count<max;count++)
                                 {
                                     //printf("%-15s\t%-15s\t%-15s\t",studname[count],classname[count],subjectname[count]);

                                      for (int k=0; k<1;k++)

                                      {

                                           printf("%-5d\n",gradeavg[count][k]);
                                      }
                                 }
               }

 }

 void Exam_Grade(char studname[][25],int examMarks[][2], int MaxExamTest[][2],int Examperctage[][2],int examAvg[][1],int finalExamgrade[][1],int paperweight[][2])
 {
 int countExavg=0;
 		for(int m=0;m<max;m++)
        	{
         	for(int z=0;z<2;z++)
            {
               if(paperweight[m][z]!=0)
                  {
                  Examperctage[m][z]=(examMarks[m][z]/MaxExamTest[m][z])*paperweight[m][z];
                  }
                  	else
             		 	{
                     Examperctage[m][z]=(examMarks[m][z]/MaxExamTest[m][z])*100;

                   	}

                finalExamgrade[m][z]=finalExamgrade[m][z]+Examperctage[m][z];
            }
            
         }

         		while(countExavg<max)
                 {
                 for(int x=0;x<1;x++)
                   {
                     examAvg[countExavg][x]=finalExamgrade[countExavg][x]/2;

 						  }
                   countExavg++;
                  }

 }


/*void Cal_semester_Grade(char studname[][25],int gradeavg[][3],int examAvg[][1])
{
	for(int e=0;e<max;e++)

    {
         /*for(int f=0; f<1;f++)
         //{
            semesteravg[e][f]=(gradeavg[e][f]+examAvg[e][f])/2;
         }
     }

//void Search_name( )?
  */
//getch();
//}






/*int grade1,grade2,grade3,gradeavg[30];
printf("Please enter Class grade");
scanf("%d%d%d",&grade1,&grade2,&grade3);
gradeavg[30]=(grade1+grade2+grade3)/3;
}

void Exam_grade()
{
int exam1,exam2,examavg[30];
printf("Please enter Exam grade");
scanf("%d%d",&exam1,&exam2);
examavg[30]=(exam1+exam2/2);
}

//////void Cal_semester_Grade//////

getch ();
}}
 */
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ancient Dragon
0

You need to fix all the errors before attempting to execute the program. Compile it with a C compiler instead of C++ -- most c++ compilers will compile files with *.c extension as C code, not C++. There were about 90 errors when I tried to compile it with VC++ 2008 Express.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.