Question: Can someone make it so my code: #include struct StudentRecord { int id; int Quiz1, Quiz2; int mid, Final; char lgrade; double average; }; void
Can someone make it so my code:
#include
struct StudentRecord
{
int id;
int Quiz1, Quiz2;
int mid, Final;
char lgrade;
double average;
};
void input(struct StudentRecord *student) //should prompt for input for one student and set the structure variable members.
{
printf("Enter student number: ");
scanf("%d", &student->id);
printf("Enter two 10-point quizzes: ");
scanf("%d %d", &student->Quiz1, &student->Quiz2);
printf("Enter mid and Final grades. These are 100-point tests: ");
scanf("%d %d", &student->mid, &student->Final);
}
void computeGrade(struct StudentRecord *student) //use this to calculate the numeric average and letter grade.
{
double average = 0;
average = (double)(student->Final * 50 + student->mid * 25 + (student->Quiz1 + student->Quiz2) * 25) / 100;
student->average = average;
if (average > 90)
{
student->lgrade = 'A';
}
else if (average >= 80 && average < 90)
{
student->lgrade = 'B';
}
else if (average >= 70 && average < 80)
{
student->lgrade = 'C';
}
else if (average >= 60 && average < 70)
{
student->lgrade = 'D';
}
else
{
student->lgrade = 'F';
}
}
void output(const struct StudentRecord student) //outputs the student record.
{
printf("The record for student number %d ", student.id);
printf("The quiz grades are %d and %d ", student.Quiz1, student.Quiz2);
printf("The mid and final grades are %d and %d ", student.mid, student.Final);
printf("The numeric average is %.2lf ", student.average);
printf("The letter grade assigned is %c ", student.lgrade);
}
int main()
{
struct StudentRecord students[5];
for (int i = 0; i < 5; i++)
{
input(&students[i]);
computeGrade(&students[i]);
}
for (int i = 0; i < 5; i++)
{
output(students[i]);
printf(" ");
}
return 0;
}
Gets this output.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
