Questions 1-3 deal with a program to grade student tests. Assume that the follow
ID: 3733838 • Letter: Q
Question
Questions 1-3 deal with a program to grade student tests. Assume that the following constants has been defined: const int NUM_QUESTIONS = 10; //you can call it NUM_Q const int NUM_STUDENTS = 50; //you can call it NUM_S
1) Define a struct called StudentTest that can be used to store a student's name (string), their answers to NUM_QUESTIONS number of multiple choice questions (stored as an array of characters - each value will be A/D/C/D/E or blank - blank will be represented by question mark) and their score (possibly a decimal).
2) Tests are graded such that a right answer is 1 point, a wrong answer is -0.25 pts, but a question left blank is 0 pts:
Write code that will take in an array of chars representing the key (size defined by NUM_Q) and a reference to a StudentTest. It should score the student's answers against the key and set their score. (If you were lost on Q1, you can pretend test is just a plain array of chars the same length as the key and return the score).
3) Assume we have an array of students (size defined by NUM_STUDENTS). Write a function to calculate the number who passed (score of 6 or above). Assume all the tests have already been scored (the score member of each has been set correctly. (If you did not define a struct in Q1, pretend tests is an array of doubles with the scores of all the students).
Sample Scoring Criteria: Sometimes partial credit can be earned in a category. There may be answers which don't fit well with the categories listed and earna bonus or penalty to what would come from this chart struct StudentTest string name char answers[NUM Q] double score 1 5Explanation / Answer
#include<stdio.h>
const int NUM_Q=10,NUM_S=50;//NumberofQuestions and NumberofStudents
char key[]={'A','C','D','E','B','C','E','B','B','C'};//key for the test
//structure called StudentTest
struct StudentTest
{
char name[20];//to store student name
char ans[10];//answers of the current student's test
double score;//score of the current student
};
//This method will evaluates the all the students test
//with provided key and the score will be stored to
//respective student's score
void StudentsGrade(struct StudentTest TotalStudents[])
{
int i,j;
double score;
//for every student in the TotalStudents[] array
for(i=0;i<NUM_S;i++)
{
score=0;//initial score was 0
//for every question, evaluate right or wrong
for(j=0;j<NUM_Q;j++)
{
//if correct option opted
if(TotalStudents[i].ans[j]==key[j])
score=score+1;//+1 score added
//if not attemped
else if(TotalStudents[i].ans[j]=='?')
score=score+0;//0 score added
//if wrong option opted
else
score=score-0.25;//0.25 score will deducted from the total score
}
//total score will added to the respective student's score
TotalStudents[i].score=score;
}
}
//This method will count howmany students got above 6 as score
int scoreTest(struct StudentTest tests[])
{
int total=0,i;
//for every student
for(i=0;i<NUM_S;i++)
{
//if score is >=6
if(tests[i].score>=6)
total++;//increment count
}
return total;//finally return
}
//main method
int main()
{
int totalPassedStudents;//total passed students count
//array of structure, every index is a structure
struct StudentTest TotalStudents[NUM_S];
/*
fill the array with appropriate students details
such as name, options of the test
*/
//pass those data to evaluate test
StudentsGrade(TotalStudents);
//pass those data to count number of student got morethan 6
totalPassedStudents=scoreTest(TotalStudents);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.