ASCII File Processing for True-False Exam Grading, Assignments of Electrical and Electronics Engineering

This computer assignment requires students to write a program in c or c++ to read an ascii file named test.txt containing the results of a true-false exam given to a group of students. The program should read the correct answers from the first line, read students' id numbers and answers, compute and store the number of correct answers for each student, determine the average score, and print a three-column table on the screen displaying the id number, score, and grade for each student. The grades are determined based on whether the score is larger than the average score.

Typology: Assignments

Pre 2010

Uploaded on 07/28/2009

koofers-user-mjs
koofers-user-mjs 🇺🇸

4

(1)

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Assignment # 2
Due Thursday November 10th
Create an ASCII file, test.txt, as shown below using text editor. It contains the results of a true-false exam given
to a group of students. You may assume that the number of students will always be less than 20. The first line
contains the key answer representing the 10 correct answers. Starting from the second line, each line of the data
file contains the student identification number and the student’s answer to 10 true-false questions. A sentinel
value of 9999 has been used.
Write a program that reads as input the file test.txt. The program should start by readng the correct answer from
the first line into a 1-D character array named correct_answers, then do the following tasks:
1. Read the students ID numbers into a 1-D integer array named ID, and read each student’s answers
into a 1-D character array containing the answers for the current student, named current_answers. The
number of students, num_students, should be determined in the process.
2. While reading the data in (1), compute and store the number of correct answers for each student in a
1-D integer array named scores.
3. After reading all the data, determine the average score, AvgScore.
4. Finally, print a three-column table on the screen that displays the ID number, the score, and the grade
(Pass or Fail) for each student.
The grades should be determined as follows: If the score is larger than AvgScore then the grade is Pass; otherwise
the grade is Fail.
Contents of the file test.txt:
FTFFTFFTFT
1080 FTTFTFTTFT
1340 FTFTFTTTFF
1341 FTTFTTTTTT
1401 TTFFTFFTTT
1462 TTFTTTFFTF
1464 FTFFTFFTFF
1465 TTTTTTTTTT
1466 FFFFFFFFFF
1467 FTFTFFTFTF
1468 FFTTFFTTFF
1469 TTTTTFFFFF
1470 FFFFFTTTTT
9999
Note:
Your program must be written so that it could process a file with any number of students (less than 20) terminated
with a sentinel value of 9999.
Adequate comments should be placed throughout your program to briefly describe it statements.
EECE1207 Spring 2005

Partial preview of the text

Download ASCII File Processing for True-False Exam Grading and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

Computer Assignment # 2

Due Thursday November 10

th Create an ASCII file, test.txt, as shown below using text editor. It contains the results of a true-false exam given to a group of students. You may assume that the number of students will always be less than 20. The first line contains the key answer representing the 10 correct answers. Starting from the second line, each line of the data file contains the student identification number and the student’s answer to 10 true-false questions. A sentinel value of 9999 has been used. Write a program that reads as input the file test.txt. The program should start by readng the correct answer from the first line into a 1-D character array named correct_answers, then do the following tasks:

  1. Read the students ID numbers into a 1-D integer array named ID, and read each student’s answers into a 1-D character array containing the answers for the current student, named current_answers. The number of students, num_students, should be determined in the process.
  2. While reading the data in (1), compute and store the number of correct answers for each student in a 1-D integer array named scores.
  3. After reading all the data, determine the average score, AvgScore.
  4. Finally, print a three-column table on the screen that displays the ID number, the score, and the grade (Pass or Fail) for each student. The grades should be determined as follows: If the score is larger than AvgScore then the grade is Pass; otherwise the grade is Fail. Contents of the file test.txt: FTFFTFFTFT 1080 FTTFTFTTFT 1340 FTFTFTTTFF 1341 FTTFTTTTTT 1401 TTFFTFFTTT 1462 TTFTTTFFTF 1464 FTFFTFFTFF 1465 TTTTTTTTTT 1466 FFFFFFFFFF 1467 FTFTFFTFTF 1468 FFTTFFTTFF 1469 TTTTTFFFFF 1470 FFFFFTTTTT 9999 Note: Your program must be written so that it could process a file with any number of students (less than 20) terminated with a sentinel value of 9999. Adequate comments should be placed throughout your program to briefly describe it statements.

EECE1207 Spring 2005