Project 3: Exam Scoring System

Due Date:  Sunday, March 20 2005, 11:59 PM

 

Introduction:

This program is supposed to generate a numerical score and a letter grade for students based on their answers for an exam. All questions on the exam are multiple choice and the answer is one from the set {A, B, C, D}. Each question has just one correct answer. There are exactly 20 questions on the exam.

 

Program details:

Your program should be in a file called ExamScore.java. All the methods and variable

declarations should be in this class. This class should also contain the main method. within the main method open the input and output files and then invoke a method called generateScores() that will process the input file and generate the output file containing student scores. Also write more methods, as you deem appropriate.

 

The program should read the student answers from an input file called students.txt. The input file comprises of the following lines:

 

  1. The first line contains the answer key in terms of ‘A’, ‘B’ ‘C’ and ‘D’ characters. An example of this line is given below.

ABCABDCCAABDCDCABBDA

Note: There are exactly 20 characters in the above string indicating answers to 20 questions.

 

  1. The next line contain a student ID followed by the character ‘|’ and then the student responses. An example of this is given below.

123456789|ABC BDCCBABDC CABCDA

  1. There could be empty spaces between the answer characters indicating that the student did not answer the question. In the above example, the student did not answer questions 4 and 14.
  2. The number of students in the input file is not fixed. Assume that there will be atleast one student line.
  3. Each correct answer is worth 5 points, each incorrect answer is worth –2 points and unanswered question is worth 0 points. Your program should compare the student responses to the key provided and generate an aggregate score for the exam.

 

The output file should be named scores.txt and contain the following information:

  1. The first line printed out should be your name. The second line should be the string “Exam scoring program”. An empty line should follow these two lines.
  2. After that, each line should contain the student ID followed by the exam score and the exam grade. The exam grade is a letter grade based on the following scale:

93.00 - 100.00 A

90.00 - 92.99 A-

87.00 - 89.99 B+

83.00 - 86.99 B

80.00 - 82.99 B-

77.00 - 79.99 C+

73.00 - 76.99 C

70.00 - 72.99 C

67.00 - 69.99 D+    

63.00 - 66.99 D

60.00 - 62.99 D-

    0 - 59.99 F

 

An example line is shown below:

123456789 94.00 A

 

  1. The last line in the output should printout average score for all the students.

 

An example is shown below:

                                Average score: 75.50

 

Hints

  1. Refer to the Java API at http://java.sun.com/j2se/1.4.2/docs/api/ whenever you need to get more information about particular classes.
  2. If  you read in the student responses as a string, use the charAt() method of the String class to extract individual answers from the String.
  3. Another class of interest will be StringTokenizer.
  4. Declare your exam score variables to be of type double.
  5. Use the following code for formatting the exam scores to contain exactly two numbers after the decimal point. First you need to import the java.text.DecimalFormat class.

 

Assume that examscore is a variable of type double.

 

DecimalFormat df = new DecimalFormat();

df.setMinimumFractionDigits(2);

df.setMaximumFractionDigits(2);

String str = df.format(examscore);

 

The String str will then contain the formatted number for printing out.

 

Programming Standards

 

Make sure you use javadoc to comment your code.

You'll be expected to observe good programming and documentation standards. You will be expected to follow these standards and others in all of your later programs. Some, specifics include:

 

Testing

You should test your program within the BlueJ environment to make sure that you implemented all the above requirements correctly. Later, you will be provided with test files to test your program with. You should be certain that your program produces the output given above when you use the given input file and the sample test files provided on the course web site. However, verifying that your program produces correct results on a few test cases does not constitute a satisfactory testing regimen. You should make up and try additional input files as well; of course, you'll have to determine what the correct output would be. Your program for this project is a stand-alone program. No other program will invoke its methods.

 

 

Submitting your Program

More information on how to submit your program will be provided in short time.

 

Pledge

Every program submission for this class must include an Honor Code pledge. Specifically, you must always include the following pledge statement in the header comment for your program:

 

/****************************************************************

*

* On my honor:

*

* - I have not discussed the Java language code in my program

* with anyone other than my instructor or the teaching assistants

* assigned to this course.

*

* - I have not used Java language code obtained from another

* student, or any other unauthorized source, either modified or

* unmodified.

*

* - If any Java language code or documentation used in my program

* was obtained from another source, such as a text book or course

* notes, that has been clearly noted with a proper citation in

* the comments of my program.

*

* - I have not designed this program in such a way as to defeat

* or interfere with the normal operation of the Curator System.

*

* Your Name

* Your PID

***************************************************************/

 

Failure to include this pledge in a submission is a violation of the Honor Code.