Due: 2/27/02

We overlooked a big problem with the first version of the New York drivers' license numbers: what if a name does not have enough letters to get all the numbers we want? Then we should set the number for the missing letter to zero. How can I take care of that?

  1. We should be sure that all values in the lname, fname and minit arrays are zeros (the null character) before we start. Then when we look at the characters to find their number we will check whether they are 'a'-'z' or not. If not, we will set the number to zero. Here are the new declarations for lname, fname and minit with all null characters:
  2. char fname[20]={'\0'}, lname[20]={'\0'}, minit[2]={'\0'};

    They will replace the old. Instead of calculating numbers in the old way we must now check that the letter is in the proper range before we map it. Here is the code for the 1st number (i.e. from the 2nd letter of last name):

    if (lname[1]='a' && lname[1]<='z')

        n1=lname[1]-'a'+1;
    else   n1=0;
  3. The new York drivers' license number formula actually has a few more complications. What do we do when a name is too short to have all the letters we need numbers from. Consider the last name. There are three different cases on the last name that affect the calculation of the first 12 digits. They are given in the table below:
  4. =4 characters

    i.e. n3!=0

    result = 10017758323.0*n1 + 371538441.0*n2 + 13779585.0*n3 + 510355.0*n4 

    + 19657.0*n5 + 729.0*n6 + 27.0*n7 + n8- 385829132.0;

    3 characters

    i.e. n2!=0 && n3==0

    result = 10017758323.0*n1 + 371538441.0*n2 + 13779585.0*n3 + 510355.0*n4 

    + 19657.0*n5 + 729.0*n6 + 27.0*n7 + n8- 385318778.0;

    2 characters

    i.e. n1!=0 && n2==0

    result = 10017758323.0*n1 + 371538441.0*n2 + 13779585.0*n3 + 510355.0*n4 

    + 19657.0*n5 + 729.0*n6 + 27.0*n7 + n8- 371539194.0;

  5. If the first name has exactly 1 letter (n6==0 && n5!=0) add 26 to the 'twelve digit' number before printing it. 
  6. We have talked in class about how to fix the problem with sex. In this new program the user should enter either M or F and your program will set sex to 0 or 1 respectively, before calculating the 3-digit number part of the DL number.


To test your program use the example of Julia Ho in the text. Be sure the old example still works!

Send (e-mail) your final code to riggs @ cis.famu.edu with the subject: COP2221 prg3 <yourname>


NOTA BENE: There are still possible problems. Some we can fix easily (e.g. what if they use capital letters) some would take more time. We will leave it at this for the sake of simplicity.