### Need some help with Class Average Calculator

I have to create a class average grade calculator for my C++ and having some major trouble. I am very new to programming and have been having trouble catching up. I had to modify this code to work with my program requirements but can't get it to work.

#include<stdio.h>

int Test;
int Quiz;
int Program;
float TestAve;
float QuizAve;
float ProgramAve;

void StudAverage();

void StudAverage()
{
int sum=0;
float StudAvg=0;
int n;
printf("\nEnter number of Program grades : ");
scanf("%d",&Program);
printf("\nEnter number of Quiz grades : ");
scanf("%d",&Quiz);
printf("\nEnter number of Test grades : ");
scanf("%d",&Test);

for(n=1;n<=Student;n++)
{
printf("\nStudent %d\n",n);
sum=0;
float t;
for(int i=0;i<Program;i++)
{
do
{
printf("Enter Program Grade %d :",i+1 );
scanf("%f",&t);
/*test if user is entering a valid number*/
}

TestAve=sum/Test;

sum=0;
for(int i=0;i<Quiz;i++)
{
do
{
printf("Enter Quiz Grade %d :",i+1 );
scanf("%f",&t);
/*test if user is entering a valid number*/
}

QuizAve=sum/Quiz;

sum=0;
for(int i=0;i<Program;i++)
{
do
{
printf("Enter Homework Grade %d :",i+1 );
scanf("%f",&t);
/*Valid number?r*/
}
ProgramAve=sum/Program;

/* Calculate & display Student Average*/
StudAvg=(.5*TestAve) + (.3*QuizAve) + (.2*ProgramAve);
printf("\nStudent Average = %.2f\n",StudAvg);

}//end for

}
{
int ch=0;
do{
printf("1 - Student Average\n");
printf("2 - Quit\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
StudAverage();
break;
case 2:
return;
}
}while(ch!=2);
}
int main(void)
{

return 0;
}

Last edited on
Topic archived. No new replies allowed.