Write a program to calculate the final or interim grades for the class. The calc
ID: 3800173 • Letter: W
Question
Write a program to calculate the final or interim grades for the class. The calculation would involve points obtained by a number of students in various assignments, quizzes, projects, midterm exams and the final exam. Please use the same grading rubric to allocate the percent-wise share under different heads as indicated in the syllabus posted on eLearning for your course. It is also indicated as follows: Grading Rubric Exams (2) 20% (each) Final Exam 25% Assignments, Quizzes, Projects 30% (One worst performance dropped) Attendance 5% You can declare and initialize a 2-D array containing the grade points and attendance of the students inside the program (or you could do this using structures). You can design the array so as to keep the assignments, quizzes and projects at the beginning of the array, followed by the midterm, then the final and the attendance at the end. Identify individual students through a simple student number that could be an integer starting from 1 and then counting ahead. Please keep in mind that if you are calculating interim grades, the points from some heads viz. the final exam might not be available at the time. You will need to drop one worst performance from assignments, quizzes and projects from calculation (but not from the exams or attendance. Assume that all evaluations have a common denominator (maximum points) of 100 points. You will need to calculate the attendance percentage values for the students using the classes attended by the students and the total number of classes held. While the attendance values can be set using the same array as the one used for the grade points, you should set the total number of classes held at the beginning of the program. These two could then be used to calculate the attendance percentage. While calculating this value, bump any fractional values to the next higher integer. For example, an attendance of Your program has to be flexible in the number of students being considered for grading, the number of assignments, quizzes or projects and should be able to consider any specified number of students for grading with any number of assignments at different points of time in the course, so please do not hard code any limiting valuesExplanation / Answer
#include <stdio.h>
#include <ctype.h>
#define NAME_LEN 50
#define STUD_LEN 100
int read_line(char str[], int n);
int find_students(int students);
struct test_result {
char name[NAME_LEN+1];
int number;
int grade1;
int grade2;
int midterm;
int final;
float numeric;
}studen[STUD_LEN];
void insert(void);
void print(void);
int num_students = 0;
int main(void)
{
struct test_result test;
printf("Enter the student's name: ");
read_line(test.name, NAME_LEN);
printf("Enter the student's grade for quiz #1: ");
scanf("%d", &test.grade1);
printf("Enter the student's grade for quiz #2: ");
scanf("%d", &test.grade2);
printf("Enter the student's grade for midterm: ");
scanf("%d", &test.midterm);
printf("Enter the student's grade for final: ");
scanf("%d", &test.final);
test.numeric = (((test.grade1 + test.grade2) * 1.25) + (test.midterm * 0.25) + (test.final * 0.50));
printf("%s's numeric score for the entire course is %.1f ", test.name, test.numeric);
char code;
for (;;) {
printf(" ");
printf("Would you like to enter another student record? y(yes) or n(no)?");
scanf(" %c", &code);
while (getchar() != ' ') /* skips to end of line */
;
switch (code) {
case 'y': insert();
break;
case 'n': print();
return 0;
default: printf("Invalid entry. Try again. ");
return 0;
}
}
}
int find_students(int students)
{
int i;
for (i = 0; i < num_students; i++)
if (studen[i].number == students)
return i;
return -1;
}
void insert(void)
{
int part_number;
if (num_students == STUD_LEN) {
printf("Sorry, cannot enter any more students. ");
return;
}
studen[num_students].number = part_number;
printf("Enter the student name: ");
read_line(studen[num_students].name, NAME_LEN);
printf("Enter the student's grade for quiz #1: ");
scanf("%d", &studen[num_students].grade1);
printf("Enter the student's grade for quiz #2: ");
scanf("%d", &studen[num_students].grade2);
printf("Enter the student's grade for midterm: ");
scanf("%d", &studen[num_students].midterm);
printf("Enter the student's grade for final: ");
scanf("%d", &studen[num_students].final);
studen[num_students].numeric =
(((studen[num_students].grade1 + studen[num_students].grade2) * 1.25) + (studen[num_students].midterm * 0.25) + (studen[num_students].final * 0.50));
printf("%s's numeric score for the entire course is %.1f ", studen[num_students].name, studen[num_students].numeric);
num_students++;
}
void print(void)
{
printf("The average score on quiz1 is ");
printf("The average score on quiz2 is ");
printf("The average score on midterm is ");
printf("The average score on the final is ");
printf("The average score for the entire course is ");
}
int read_line(char str[], int n)
{
int ch, i = 0;
while(isspace(ch = getchar()))
;
str[i++] = ch;
while ((ch = getchar()) != ' ') {
if (i < n)
str[i++] = ch;
}
str[i] = '';
return i;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.