grades.c grades.c will contain 2 functions, grade and gradePrint. grade will do the following: • Receive 9 positive integers. The first 4 integers will be the student average for attendance, assignments, programs and quizzes. The 5 integer will be the final exam grade. The last 4 integers will represent the percentage values for the attendance, assignments, programs, and quizzes. • Return an integer that will be the final grade for the course. . If any grade received is less than 0 or more than 105, the function will return -1. If any percentage received is less than 0 or more than 100, the function will return . • • The sum of all the percentages can not exceed 100. If they do, the function will return-3. • The percentage for the final will be computed as the difference between the sum of the percentages received and 100. gradePrint will do the following: • Receive an integer that represents the numeric grade for the course. . If the integer received is not in the range of 0-105, then the error message"## is not a valid grade", where ## is the value received. It will then exit with a value of 1 • Convert the course numeric grade into a letter grade. See the class syllabus final grade assignments to do the conversion. Note: A+ goes to a grade of 105 Display the course grade and a message using the following and return a value of 0: • • grade A+, A, or A- Message: Excellent grade B+, B, or B- Message: Good grade C+, C, or C- Message: Fair grade D+, D, or D- Message: Poor grade F Message: Failing Grade

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

[This is not a graded assignment! ]
Please help me modify this code. It is complete and it runs perfectly :], but does not follow the assignment. 

Main

#include <stdio.h>
#include "grades.h"

int main() {
    Student students[] = {
        {"Adams, Tom", {95, 93, 95, 99, 94}, 90, 85, 80, 75},
        {"Curry, Jane", {95, 86, 88, 87, 89}, 90, 85, 80, 75},
        {"Franklin, John", {70, 50, 65, 50, 57}, 90, 85, 80, 75},
        {"George, Pat", {85, 78, 81, 82, 88}, 90, 85, 80, 75},
        {"Keene, Mary", {85, 72, 75, 68, 75}, 90, 85, 80, 75},
        {"Kraft, Martin", {80, 85, 80, 88, 93}, 90, 85, 80, 75},
        {"Martin, James", {75, 65, 65, 52, 55}, 90, 85, 80, 75},
        {"Oakley, Ann", {95, 85, 95, 88, 92}, 90, 85, 80, 75},
        {"Smith, Luke", {95, 85, 75, 81, 75}, 90, 85, 80, 75},
    };
    int num_students = sizeof(students) / sizeof(Student);
    int i;

    for (i = 0; i < num_students; i++) {
        Student student = students[i];
        double grade = calculate_final_grade(&student);
        char* letter_grade = get_letter_grade(grade);
        char message[50];

     get_message(letter_grade, message);

        printf("%s %s\n", student.name, message);
    }

    return 0;
}

Grade.h 

#include <stdio.h>
#include "grades.h"

int main() {
    Student students[] = {
        {"Adams, Tom", {95, 93, 95, 99, 94}, 90, 85, 80, 75},
        {"Curry, Jane", {95, 86, 88, 87, 89}, 90, 85, 80, 75},
        {"Franklin, John", {70, 50, 65, 50, 57}, 90, 85, 80, 75},
        {"George, Pat", {85, 78, 81, 82, 88}, 90, 85, 80, 75},
        {"Keene, Mary", {85, 72, 75, 68, 75}, 90, 85, 80, 75},
        {"Kraft, Martin", {80, 85, 80, 88, 93}, 90, 85, 80, 75},
        {"Martin, James", {75, 65, 65, 52, 55}, 90, 85, 80, 75},
        {"Oakley, Ann", {95, 85, 95, 88, 92}, 90, 85, 80, 75},
        {"Smith, Luke", {95, 85, 75, 81, 75}, 90, 85, 80, 75},
    };
    int num_students = sizeof(students) / sizeof(Student);
    int i;

    for (i = 0; i < num_students; i++) {
        Student student = students[i];
        double grade = calculate_final_grade(&student);
        char* letter_grade = get_letter_grade(grade);
        char message[50];

     get_message(letter_grade, message);

        printf("%s %s\n", student.name, message);
    }

    return 0;
}

grades.c

#include <stdlib.h>
#include <stdio.h>
#include "grades.h"

double calculate_final_grade(Student* student) {
    double assignment_weight = 0.40;
    double midterm_weight = 0.15;
    double final_exam_weight = 0.35;
    double participation_weight = 0.10;

    double total_grade = 0.0;

        int i;
    for (i = 0; i < 5; i++) {
        total_grade += student->grades[i];
    }

    double average_grade = total_grade / 5.0;

    total_grade = (average_grade * assignment_weight) + (student->midterm * midterm_weight)
            + (student->final_exam * final_exam_weight) + (student->participation * participation_weight);


    return total_grade;
}

char* get_letter_grade(double grade) {
    if (grade >= 90.0) {
        return "A";
    } else if (grade >= 80.0) {
        return "B";
    } else if (grade >= 70.0) {
        return "C";
    } else if (grade >= 60.0) {
        return "D";
    } else {
        return "F";
    }
}

void get_message(char* letter_grade, char* message) {
    if (letter_grade[0] == 'A') {
        sprintf(message, "is doing excellent work");
    } else if (letter_grade[0] == 'B') {
        sprintf(message, "is doing good work");
    } else if (letter_grade[0] == 'C') {
        sprintf(message, "is doing satisfactory work");
    } else if (letter_grade[0] == 'D') {
        sprintf(message, "is doing below average work");
    } else {
        sprintf(message, "is failing the course");
    }
}

Compile the 3 codes to a makefile to follow the example!
Thank you, much appreicated 


grades.c
grades.e will contain 2 functions, grade and gradePrint.
grade will do the following:
• Receive 9 positive integers. The first 4 integers will be the student average for
attendance, assignments, programs and quizzes. The 5 integer will be the final
exam grade. The last 4 integers will represent the percentage values for the
attendance, assignments, programs, and quizzes.
•
•
•
CIS158
gradePrint will do the following:
•
•
Return an integer that will be the final grade for the course.
If any grade received is less than 0 or more than 105, the function will return -1.
If any percentage received is less than 0 or more than 100, the function will return
-2
The sum of all the percentages can not exceed 100. If they do, the function will
return -3.
The percentage for the final will be computed as the difference between the sum
of the percentages received and 100.
.
Receive an integer that represents the numeric grade for the course.
If the integer received is not in the range of 0-105, then the error message "##
is not a valid grade", where ## is the value received. It will then exit with a value
of 1
Convert the course numeric grade into a letter grade. See the class syllabus final
grade assignments to do the conversion. Note: A+ goes to a grade of 105
• Display the course grade and a message using the following and return a value of
0:
• grade A+, A, or A- Message: Excellent
•
grade B+, B, or B- Message: Good
grade C+, C, or C- Message: Fair
grade D+, D, or D- Message: Poor
grade F Message: Failing Grade
Programming Assignment P06
CIS158 Programming Assignment - P06
Grades
Example of Output (only for first 3 entries)
Adams, Ton
Grade A
Curry, Jane
Grade B+
Franklin, John
Grade F
Excellent
Good
Failing Grade
Page 2 of 3
Transcribed Image Text:grades.c grades.e will contain 2 functions, grade and gradePrint. grade will do the following: • Receive 9 positive integers. The first 4 integers will be the student average for attendance, assignments, programs and quizzes. The 5 integer will be the final exam grade. The last 4 integers will represent the percentage values for the attendance, assignments, programs, and quizzes. • • • CIS158 gradePrint will do the following: • • Return an integer that will be the final grade for the course. If any grade received is less than 0 or more than 105, the function will return -1. If any percentage received is less than 0 or more than 100, the function will return -2 The sum of all the percentages can not exceed 100. If they do, the function will return -3. The percentage for the final will be computed as the difference between the sum of the percentages received and 100. . Receive an integer that represents the numeric grade for the course. If the integer received is not in the range of 0-105, then the error message "## is not a valid grade", where ## is the value received. It will then exit with a value of 1 Convert the course numeric grade into a letter grade. See the class syllabus final grade assignments to do the conversion. Note: A+ goes to a grade of 105 • Display the course grade and a message using the following and return a value of 0: • grade A+, A, or A- Message: Excellent • grade B+, B, or B- Message: Good grade C+, C, or C- Message: Fair grade D+, D, or D- Message: Poor grade F Message: Failing Grade Programming Assignment P06 CIS158 Programming Assignment - P06 Grades Example of Output (only for first 3 entries) Adams, Ton Grade A Curry, Jane Grade B+ Franklin, John Grade F Excellent Good Failing Grade Page 2 of 3
Program Name
cis 158g1
Description
The program will compute the final grade for the students listed below.
The program will use the following files cis 158g1.c, grades.c, and grades.h
The program will use format and words displayed in the Example of Output.
Requirements
cis 158g1.c
Will contain only one function, main. It will do the following:
•
Will use the functions in grades.c to complete display a grade for each student
listed in the table below.
•
The students listed below, their grade averages, and percentages for each category
are to be hard coded in the function.
•
For the message format listed below, the students name is to be produced by the
main function.
•
The final grade both numeric and letter are to be produced by the functions in
grades.c
Name
Adams, Tom
Curry, Jane
Franklin, John
George, Pat
Keene, Mary
Kraft, Martin
Martin, James
Oakley, Ann
Smith, Luke
Attendance Assignment
5%
20%
93
95
95
70
85
85
80
75
95
95
86
50
78
72
85
65
85
85
Programs Quiz Final
35%
25%
95
88
65
81
75
80
65
95
75
grades.h
Will only contain the prototypes for all the functions in grade.c
99
87
50
82
68
88
52
88
81
94
89
57
88
75
93
55
92
75
Transcribed Image Text:Program Name cis 158g1 Description The program will compute the final grade for the students listed below. The program will use the following files cis 158g1.c, grades.c, and grades.h The program will use format and words displayed in the Example of Output. Requirements cis 158g1.c Will contain only one function, main. It will do the following: • Will use the functions in grades.c to complete display a grade for each student listed in the table below. • The students listed below, their grade averages, and percentages for each category are to be hard coded in the function. • For the message format listed below, the students name is to be produced by the main function. • The final grade both numeric and letter are to be produced by the functions in grades.c Name Adams, Tom Curry, Jane Franklin, John George, Pat Keene, Mary Kraft, Martin Martin, James Oakley, Ann Smith, Luke Attendance Assignment 5% 20% 93 95 95 70 85 85 80 75 95 95 86 50 78 72 85 65 85 85 Programs Quiz Final 35% 25% 95 88 65 81 75 80 65 95 75 grades.h Will only contain the prototypes for all the functions in grade.c 99 87 50 82 68 88 52 88 81 94 89 57 88 75 93 55 92 75
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education