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?
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;
|
=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; |
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.