CS 54 - Lab 9


Lab Assignment

The Clayton Price Institute of Higher Learning has hired you to test the AJ Fallgren Conjecture: that given a CS 53 student, the grade can be mathematically determined based on the student's name regardless of the assignment content.


Lab Assignment - Part I (Required - 8 Points)

The Fallgren Conjecture states that the score can be determined by first enumerating the letters as the alphabet as A = 1, B = 2, C = 3, ..., Z = 26 (HINT: you may find it easiest to take the student's name and convert every letter to an upper case letter one-by-one using the toupper() function by including cctype). This number is then multiplied by the position in the name it is starting from one. All the resulting numbers are then summed up and then divided by 26 times the number of letters in the name.

For example, the name “Kate” works out to be:
K A T E = (11 × 1 + 1 × 2 + 20 × 3 + 5 × 4) / (26 × 4) = 93 / 104 = .8942

Write a function double fallgren(char studentName[]); that will calculate the grade based on the Fallgren Conjecture for a NUL terminated character array studentName.


Lab Assignment - Part II (Required - 10 Points)

Another computer scientist at the Price Institute, Stephen Mues, claimed that the Fallgren Conjecture was fundamentally unfair since some students could get over 100% if they had lots of letters later in the alphabet in their name. So Mues wrote a lemma stating the Fallgren grade would be more fair if it was multiplied by the ratio of the number of consonants by the name length (HINT: It may be easier to count the number of vowels instead and then subtract this from the name length for this Part; also, assume y is a consonant and not a vowel).

For example, for the name “Dylan”, we first get the Fallgren score:
D Y L A N = (4 × 1 + 25 × 2 + 12 × 3 + 1 × 4 + 14 × 5) / (26 × 5) = 164 / 130 = 1.2615
Now we multiply by the ratio of the number of consonants by the name length (4 / 5):
1.2615 * 0.8 = 1.0092

Write a function double mues(char studentName[], double fallgrenScore); that will calculate the grade based on the Mues Lemma for a NUL terminated character array studentName.


Lab Assignment - Part III (Extra Credit - 12 Points)

Another member of the Clayton Price Institute Unfair Grading Team, Kate Holdener, suggested that instead of using the quick sum method that Fallgren used, a geometric mean of the values may be more appropriate. The Geometric mean of a sequence is:
\left(\prod_{i=1}^n a_i \right)^{1/n} = \sqrt[n]{a_1 \cdot a_2 \cdot \dots \cdot a_n}

Write a function double holdener(char studentName[]); that will calculate the grade based on the Holdener Hypothesis for a NUL terminated character array studentName.


Grading & Submission


[Dilbert]