Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone help fix this code, I'm not getting the correct output and I do not know why. #include struct StudentRecord { int id; int

can someone help fix this code, I'm not getting the correct output and I do not know why.

#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 = 'E'; } } 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 finalgrades 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; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions