Letter Grade -- Table Lookup

Computer Methods in Chemical Engineering


Problem Statement: Write a program to calculate the fractional points earned by each student in a class based on the total of eleven homework scores, four best quiz scores out of five, and the final exam grade. The weight of each category is given below.

   Homework     30%
   Quizzes      35%
   Final Exam   35%
Based on the fractional points, assign a letter grade to each student according to the following scheme.
   % Pts Earned   Grade
   --------------------
      90-100        A
      80- 89        B
      70- 79        C
      60- 69        D
       0- 59        F
An example of the input is shown below. The user input is everything but the overall fractional grade and the letter grade.
                       Homework            Quiz         Total        Grade
                --------------------- -------------- ------------- ---------
Student Name    #1 #2 #3 ... #9 10 11 #1 #2 #3 #4 #5 hw quiz final fract Letter
Fraction (%)                                         30% 35% 35%
------------------------------------- -------------- ------------- --------
Possible Score  10 10 20 ... 20 20 20 50 50 50 50 50 180 200 100   1.000 A
------------------------------------- -------------- ------------- --------
Wang, Nam       10 10 20 ... 20 20 15 50 50 50 29  0 173 179  83   0.829 B
Doe, John       10 10 20 ... 20 19 11 60 40 60 50 43 167 213  62   0.794 C
Big, Foot       10 10 10 ... 20 16  9 40 40 40 39 46 148 164  44   0.630 D
    :            :  :  :  :   :  :  :  :  :  :  :  :  :   :    :      :
------------------------------------- -------------- ------------- --------
Average

Solution:


Problem Statement: You have a file named grade.dat that contains numerical student scores in a class in the following format. The first three lines are the table header.

   --------------------
   Student Name   Score
   --------------------
   12345678901234 0.563
   Perfect, Goody 1.000
   Wang, Nam      0.954
   Doe, John      0.347
   Piggy, Miss    0.457
   Frog, Kermit   0.842
   Bird, Big      0.730
       :            :
       :            :
Write a FORTRAN program to input the name and scores from the file, count the total number of students, convert the scores to letter grades according to the following scheme.
   -----------------------
     Score   Grade  Number
   -----------------------
   0.80-1.00   A      4
   0.65-0.80   B      5
   0.50-0.65   C      3
   0.40-0.50   D      :
   0.00-0.40   F      :
   -----------------------
   Total              :
Calculate the distribution of grades in the class and print out a summary table (see the one shown above). Finally, print out a separate table which retains the same format as the original score data but with a new column of letter grades added. (see the one shown below).
   --------------------------
   Student Name   Score Grade
   --------------------------
   12345678901234 0.563   C
   Perfect, Goody 1.000   A
   Wang, Nam      0.954   A
   Doe, John      0.347   F
   Piggy, Miss    0.457   D
   Frog, Kermit   0.842   A
   Bird, Big      0.730   B
       :            :     :
       :            :     :

Solution:

c ----------------------------------------------------------------------
c Input the name and scores from a file "grade.dat", which contains student
c scores in a class in the following format.
c     --------------------
c     Student Name   Score
c     --------------------
c     12345678901234 0.563
c     Perfect, Goody 1.000
c         :
c         :
c     --------------------
c
c Count the total number of students, convert the scores to letter grades
c according to the following scheme.
c     ---------------
c       Score   Grade
c     ---------------
c     0.80-1.00   A
c     0.65-0.80   B
c     0.50-0.65   C
c     0.40-0.50   D
c     0.00-0.40   F
c     ---------------
c
c ----------------------------------------------------------------------
c Instructor: Nam Sun Wang
c ----------------------------------------------------------------------

      parameter (nmax=100)
      character name(nmax)*14, grade(nmax)*1
      real score(nmax)

c Proram Header --------------------------------------------------------
      print *, 'Calculate letter grades from numerical scores.'

      open (1, file='grade.dat')

c Skip the 3-line header -----------------------------------------------
      do i=1, 3
        read(1, 500) name(1)
      enddo

c Handle scores --------------------------------------------------------
      do i=1, nmax

c Read in various scores -----------------------------------------------
1       read(1, 500, err=1, end=11) name(i), score(i)

c Assign letter grades based on a lookup table -------------------------
c Count the frequencies, as well
        if     ( score(i) .ge. 0.8 ) then
          grade(i) =  'A'
          na = na+1
        elseif ( score(i) .ge. 0.65) then
          grade(i) =  'B'
          nb = nb+1
        elseif ( score(i) .ge. 0.55) then
          grade(i) =  'C'
          nc = nc+1
        elseif ( score(i) .ge. 0.40) then
          grade(i) =  'D'
          nd = nd+1
        else
          grade(i) =  'F'
          nf = nf+1
        endif

      enddo

11    close (1)

c Total number of points handled (The last line does not count.)--------
      ntotal = i-1

c Print out a summary of grade distribution ----------------------------
      print *, ' '
      print *, '-----------------------'
      print *, '  Score   Grade  Number'
      print *, '-----------------------'
      print 650, ' 0.80-1.00   A',  na
      print 650, ' 0.65-0.80   B',  nb
      print 650, ' 0.50-0.65   C',  nc
      print 650, ' 0.40-0.50   D',  nd
      print 650, ' 0.00-0.40   F',  nf
      print *, '-----------------------'
      print 650, ' Total        ', ntotal

c Print out a summary of total points ----------------------------------
      print *, ' '
      print *, '--------------------------'
      print *, 'Student Name   Score Grade'
      print *, '--------------------------'
      do i=1, ntotal
        print 651, name(i), score(i), grade(i)
      enddo

c Some formats ---------------------------------------------------------
500   format(a, f6.3)
650   format(a, i8)
651   format(1x, a, f6.3, 3x, a)

      end


Problem Statement: You have a Mathcad document that contains numerical homework scores and test scores for a class of students in the following format.

Please help your instructor finish writing the document (via simulation on paper) by performing the following tasks. Compose the Mathcad worksheet in a such a way that you need not change anything else other than the score matrix when you change an individual entry or add more students.

  1. Count the total number of students.
  2. Calculate the average score for each of the homework assignments, the quizzes, and the final exam. Display your results immediately below the score matrix.
  3. Compute the fraction of points earned by each student based on the following formula. Display them to the right of the score matrix.
           sum(hw scores)         sum(qz scores)          final exam score
      f = -----------------*30% + -----------------*35% + -------------------*35%
          perfect hw scores       perfect qz scores       perfect final score
    
  4. Based on the cutoff scores shown below, convert the fractional scores to number grades consistent with our GPA system (i.e., F=0, D=1, ..., A=4). Display the number grades immediately to the right of the fractional scores from the last step. The following table should become part of your Mathcad worksheet.
       ----------------------------------------
       Fractional   Letter Number  Distribution
         Score      Grade  Grade    Frequency
       ----------------------------------------
       0.00-0.40      F   =  0          0
       0.40-0.50      D   =  1          1
       0.50-0.65      C   =  2          1
       0.65-0.80      B   =  3          :
       0.80-1.00      A   =  4          :
       ----------------------------------------
                                 Total  :
    
  5. Extra Credits Only. Calculate the distribution of grades in the class and display it to the right of the cutoff table (like the one shown above).

Solution:


Problem Statement: Here are a couple of Mathcad worksheets to handle more complicated grading schemes (e.g., more categories, dropping lowest grades, etc.)

Solution:


Return to Prof. Nam Sun Wang's Home Page
Return to Computer Methods in Chemical Engineering (ENCH250)

Computer Methods in Chemical Engineering -- Letter Grade -- Table Lookup
Forward comments to:
Nam Sun Wang
Department of Chemical & Biomolecular Engineering
University of Maryland
College Park, MD 20742-2111
301-405-1910 (voice)
301-314-9126 (FAX)
e-mail: nsw@umd.edu ©1996-2006 by Nam Sun Wang
UMCP logo