Hello, I have this problem,
Write a program for a professor to calculate the average grade of a student.The program should accept as many grades as the professor wants to enter.Therefore, ask the professor for the first grade, the second grade, and so onuntil the professor enters a negative value. A negative value indicates thatthe professor is finished entering grades. Once the professor is finished, yourprogram should output:a) the average grade of the studentb) the letter grade of the student
this is what I have so far.
Code:
#include <stdio.h>
int main ()
{
double grade, s, total_firstgrade=0, total_secondgrade=0,average=0; //declare the variables
do
{
printf("\nEnter the student grade: "); //asking the user to enter a integer
scanf("%lf",&grade);
printf
if(f==-1||f<=0)
break;
else
{
printf("Enter the student grade: ");
scanf("%lf",&s);
//calculation of the average
total_firstgrade+= f;
total_secondgrade+= s;
average:total_firstgrade+total_secondgrade/average;
}
} while (1);
if (f<=0&& f!=-1)
printf("first grade cannot be 0 or negative other than -1 to stop\n");
if (total_firstgrade==0)
printf("total first grade is 0, no average calculated\n");
else
printf("\nthe average of the student is: %lf\n",average);
//using the if statement to find the student average grade
if (s>100|| s,0)
printf("non-valid average");
else
{
if (s>=0)
if (s<60)
printf("F\n");
else if (s<70)
printf("D\n");
else if (s<80)
printf("C\n");
else if (s<90)
printf("B\n");
else if (s<=100)
printf("A\n");
}
}
The thing is that it does not make the average. I would like to know what can I do to fix this problem. Thank You!