In this lab you will write a program to grade a set of multiple choice exams. The input to the program has two parts. The first part contains the answer key, and the second part contains the students' answers to the test. The output will be a list of students with their exam grades, and the average grade for the exam.
This program will use two input files. One file will contain the answer key for the test. The other file will contain the student names and test answers.
The answer key file will contain one line. This line will contain the answers to the test questions. The answer to each question is one of the letters 'A' through 'E'. The answers will be right next to each other with no spaces in between. For example, the answer key could look like:
ACBBDAEDCACBAEEACBDBBACDEABBCACEDEB
The first line of the student file will contain an integer that tells how many students took the exam. Suppose we call that number N.
The next N lines of the student file each contain the test answers for one student, and the name of that student. The first characters on each line will be the student's answers to the test questions. The number of answers on each line will be equal to the number of answers in the answer key. For example, if the answer key contains 35 characters, then the first 35 characters on each line will be the student's answers. The answers will be followed by the student's name. The name will be entered starting with the character following the answers. Thus a line containing data for three students who took a test with 35 questions will look like:
3 ACBBDAEDCACDAEDACBDBBACDAABBCACEDEBBeatriz Palacios ACBBEAEDCACBAAEACBDBCACDDABBCDCEDBBArjun Chaudhuri BCBEDACDCADBAECACBDABACDEABBAACBCEAStephanie Zapalac
Make sure your input follows this format exactly, so that my test data will work on your program.
Your program should output one line for each student, containing the student name and their exam grade as a percentage. After the output for each student, the program should output one line with the average grade for the class. For example, given the above data, your program might output:
Student Grade Beatriz Palacios 91.4 Arjun Chaudhuri 85.7 Stephanie Zapalac 71.4 Class Average 82.8
Use functions (with parameters!) in your program.
Make sure your program works for any test, no matter how many questions it contains.
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2006