COS 126 Grades Practice Programming Exam I

Instructions. This practice exam has one question. (It is practice and not a component of your course grade.) You have 50 minutes. The practice exam is open course materials, which includes the course textbook, the companion booksite, the course website, your course notes, and code you wrote for the course. Accessing other information or communicating with a non-staff member (such as via email, instant messenger, text message, Facebook, Piazza, phone, or Snapchat) is prohibited.

Problem. Develop a Java program that takes a threshold score as a command-line argument; reads grade data from standard input; computes numerical mid-semester scores; and prints those greater than (or equal to) the specified threshold.

Standard input format. The input from standard input consists of seven columns, one for student names, four for programming assignment scores, one for the programming exam grade, and one for the written exam grade. The first line (with the special name WEIGHT) specifies weights for each assessment; the second line (with the special name MAX) specifies the maximum score for each assessment; all remaining lines specify a student name followed by the corresponding scores for that student. Here is a sample input file in the prescribed format:

% more grades1.txt
WEIGHT  12.5 12.5 12.5 12.5 15.0 35.0
MAX       20   20   20   20   30   70
Allie     16    8   16   20   25   61
Bodhi     18   19   19   20   28   59
Chaya     15   16   20   20   25   59
Donovan   10   11   11   12   21   43
Elizabeth 20   20   20   20   27   53

The weights are arbitrary real numbers (that sum to 100). You may assume that the assessment scores are integers.

Your task. For each student, compute their numerical midsemester score by adding together the weighted scores for each assessment (computed by dividing the raw score by the maximum score, and multiplying the result by the corresponding weight). For example, to compute the midsemester score for Allie, start by dividing her grade for the first assessment (16) by the maximum score for that assessment (20) and multiplying by the weight for that assessment (12.5), continuing in the same way for each assessment to compute the result:

$$\left (12.5 \times \frac{16}{20} \right ) \;+\; \left (12.5 \times \frac{8}{20} \right ) \;+\; \left (12.5 \times \frac{16}{20} \right ) \;+\; \left (12.5 \times \frac{20}{20} \right ) \;+\; \left (15.0 \times \frac{25}{30} \right ) \;+\; \left (35.0 \times \frac{61}{70} \right ) \;=\; 80.5$$

Output format. For each student with a score greater than (or equal to) the specified threshold, print a line containing their raw score (using three digits of precision after the decimal place), followed by their name.

 % java-introcs Grades 0.0 < grades1.txt 80.500 Allie 91.000 Bodhi 86.375 Chaya 59.500 Donovan 90.000 Elizabeth  % java-introcs Grades 90.0 < grades1.txt 91.000 Bodhi 90.000 Elizabeth 

Test file. For convenience, here is the sample input file grades1.txt.

Submission. Submit the file Grades.java via the link on the Class Meetings page. Be sure to click the Check All Submitted Files button to verify your submission.

Grading. If this were a real exam, your program would be graded for correctness, clarity (including comments), design, and efficiency. You would receive partial credit for a program that correctly implements some of the required functionality. You would receive a substantial penalty if your program did not compile or if you did not follow the prescribed input/output specifications.

Context. This is the procedure used to calculate midsemester grades in COS 126, using the weights from Spring 2016.