- Copy the file "grades.sav"
from the IDL exercises directory to your local directory. Then, using
the RESTORE command, "restore" it to your IDL session.
- The save file contained the variable "GRADELIST". This
is a set of actual final point scores for a UVa course.
- How many students were in the class?
- Determine the MEAN, MEDIAN, MAXIMUM, MINIMUM, and standard deviation (using
VARIANCE) for the set of scores.
- Using the SORT function, define a new list (call it "SCOREORDER")
of scores in order from lowest to highest value. Verify.
- Now define and verify a new list (call it "RANKSCORE") of
scores in order from highest to lowest value. (Hint: use REVERSE)
- Now define an auxiliary vector ("RANK") which gives the rank
of each student in the class (assigning 1 to the student with the highest
- Using a (one-line) FOR loop, an appropriately defined format string,
and the PRINT command, print on your terminal the rank and score of the
students in order from highest to lowest. Hint: the definition for
an IDL format string might look like the following (IDL format statements
are similar, but not identical, to those in FORTRAN). FORMOUT='(A12,3X,I3,3X,F8.3,3X,E10.3)'
and the command to print would look like this:
FOR I=0,MAXI DO PRINT,FORMAT=FORMOUT,VAR1[I],VAR2[I]....
- Use your rank-listing capability to determine the median of
the grade distribution. Does it agree with the value
returned by MEDIAN?
- Now assign letter grades to the students. Assume you are a tough
grader and use a strict curve where the top 10% of the class gets an
"A", the next 10% gets a "B" and so on. The lower
60% of the class will get an F in this scheme (appropriate, e.g., for a
pre-Med class). Using STRARR, define a string array named "LETTER"
to hold the letter grades for the students.
- Fill it with blanks initially. Consult the ranked list of scores from
your terminal printouts and determine the letter grade break points. Then
assign values to the "LETTER" array using those breakpoints.
[Hint: use the WHERE function.] "LETTER" should be in
the order of the original "GRADELIST".
- Verify the assignments by using a FOR statement and a new format
definition to print on your terminal a list of rankings, numerical scores,
and letter grades in ranked order.
- Now create an output file on your disk and output to it, in the
original (not ranked) order: the numerical grade, the class rank, and the
final letter grade for each student. [Hint: You already have defined an
appropriate format string. The other commands you will need are
GET_LUN, OPENW, PRINTF, and CLOSE.]
- Verify your results (e.g. use $MORE).
- Now reverse the process and read the disk file back into your IDL
session, using variables with different names. Verify the results