You are to write a C program that grades a true-false quiz. The quiz data will b
ID: 3680793 • Letter: Y
Question
You are to write a C program that grades a true-false quiz. The quiz data will be available in a text file; here is an example:
Quiz #8 (09/22/14) (corrected version)
TTFTTFTFTF
0080 TTFTTFTFTF
0340 TTFTFFTFTF
1522 TTFFFFTFTF
9001 TFFTTTTTTF
0012 FFTFTFTFTF
9013 TTFTTTFTFT
0913 TTTFFTFTTF
6155 FFTTTTTTFT
3144 FFTTFTTTFT
4400 FFTFFTFTFF
0
The first line in the data file is a comment that you may assume can be up to 80 characters long; it cannot be blank. The second line contains the answer key for the 10-question true-false quiz. The following lines in the data file contain a sutdent's id number in column 1 followed by their answers for the quiz in column 2. A 0 (zero) on a line by itself indicates that there are no more students to process.
Write a program that first reads in the comment line and answer key as strings followed by each student's data. Store the students id numbers in an array. You are to 'grade' each student's quiz using the key provided followed by recording their scores (in a second array) in order to be able to print them out later. You do not need to use an array of strings or characters in your program. Write your program allowing for up to 100 students, and you may assume that at least 1 student will have taken the quiz.
You should create test data text files and provide the data to your program using redirection
from the command line (see the sample run below). Your program should output the number
of students who took the quiz, the average score, the best score, and a table showing each
student?s id, score, and grade.
our program should determine each student?s grade as follows: if the score is equal to the
best score b or b ? 1, give an A. If it is b ? 2, award a B. Give C?s for any score that is equal
to b ? 3 or b ? 4, a D for b ? 5 and an F for all others.
Explanation / Answer
#include < stdio.h >
int main ( void )
{
char statemnt[80] ;
char result[10] ;
char students[10] ;
int n = 0 ;
int i = 0 ;
int x = 0 ;
int student_Id[10] ;
scanf ( " %[^ ] " , statemnt ) ;
printf ( " %s " , statemnt ) ;
scanf ( " %s " , result ) ;
printf ( " key = %s " , result ) ;
scanf ( " %d " , &student_Id ) ;
scanf ( " %s " , students ) ;
printf ( " %s " , students ) ;
for ( i = 0 ; i < 10 ; i++)
{
if (students[i] == result [i] )
{
printf ( "Identical... " ) ;
}
}
printf ( " result[0] = %c " , result[0] ) ;
return 0 ;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.