Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C-program which I can used to enter student ID, Quiz, Recitation, Test,

ID: 675414 • Letter: W

Question

Write a C-program which I can used to enter student ID, Quiz, Recitation, Test, and final scores and get them printed in a file “Stu_Score.txt”. The program will then open the “Stu_Score.txt” file to calculate and print the student ID and Grade in two columns on my monitor. Quizzes, recitation, test and final have all been graded out of 100 points each. However, quizzes count for 20%, recitations for 20%, tests for 30% and final for 30% of the “Total_Score”. Maximum Total_score can be 100. Depending upon the Total_Score the letter grade is determined in the following manner: 100-90: ‘A’, 89-80: ‘B’, 79-70:’C’, 69-60:’D’, and 0-59: ‘F’using “switch Case” statements.

Requirements and Hints:
1. Create variables to hold, ID, Quiz, Test, Reccitation, Final, Total scores, Grade, counter, etc.
2. Create a file pointer, open file “Stu_score.txt” for “writing”.
3. Ask the user to input 4-digit student ID, or 999 to quit.
4. While ID is not 999, keep on doing the following:
a. Ask the user to enter Quiz, test, recitation and final grade.
b. Scan them into proper variables.
c. Print them into the “file”.
d. Ask again to enter ID or 999 to quit.
e. If user enters 999 come-out of while loop.
f. Close the file.
5. Now open the file one more time to read. Read the ID, Quiz. Test, Recitation, Final Scores.
6. Determine the total score and grade (using “swich( )..case: logic) and print the ID and grade on Monitor.
7. Repeat the process, assuming that you DON’T know the class size!!
8. Your code will also calcuate the “average score” of the class, and print the following as the last line on the screen. If the mean is less than 70, then it will print “Curve your grades by a factor of (70/class_mean)= ***”, if it 70 or more than 70 then it will print “Class mean=*****”, no need to curve.

Press any key to continue . . .
“Stu_Score.txt”
1001 76.00 67.00 87.00 78.00
1002 54.00 65.00 67.00 72.00
1003 34.00 54.00 45.00 54.00
1004 67.00 87.00 98.00 98.00
1005 45.00 89.00 56.00 56.00

Explanation / Answer

CODE :

#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;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote