Question

**** C language **** Given are the variables: Lastname, Firstname, Middle Initial and their SSN. char...

**** C language ****

Given are the variables: Lastname, Firstname, Middle Initial and their SSN.

char lName[][10] = {"Brum","Carroll","Carter","Dodson","Garbus", "Greenwood", "Hilliard", "Lee", "Mann", "Notz", "Pastrana", "Rhon", "Rodriguez", "Wilson", "Zimmerman"};
char fName [][10] = {"Natalie","Cody","Sophia","Dominic","Chandler","Caleb","Sydnee","Peyton","Brianna","Zachery","Kevin","Luke","Juan","Kelci","Adam"};
char middleInitial[]={'N','L','X','L','O','L','M','B','S','T','J','C','P','D','Z'};
char social[][12]= {"164-55-0726","948-44-1038","193-74-0274","458-57-2867","093-50-1093","159-56-9731","695-21-2340","753-66-6482","852-73-4196","648-81-1456","879-61-1829","123-87-6431","248-65-3197","741-85-9632","963-25-7418"};

Would like you to convert each digit in a social security number to a character. Assume that
a capital A has a value of 65. Use that as a starting point and add each digit to it and then convert it to a
letter. Build a complete encrypted social security number. Example: social security number
"193-74-0274" would be encrypted as "BJD-HE-ACHE".

For each patient, print their full name, social security number and encrypted social
security number. Example:
Name = Ling, Hector X, SS# = 193-74-0274, Encrypted SS# = BJD-HE-ACHE

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C language code

#include<stdio.h>
int main()
{
   char lName[][10] = {"Brum","Carroll","Carter","Dodson","Garbus", "Greenwood", "Hilliard", "Lee", "Mann", "Notz", "Pastrana", "Rhon", "Rodriguez", "Wilson", "Zimmerman"};
   char fName [][10] = {"Natalie","Cody","Sophia","Dominic","Chandler","Caleb","Sydnee","Peyton","Brianna","Zachery","Kevin","Luke","Juan","Kelci","Adam"};
   char middleInitial[]={'N','L','X','L','O','L','M','B','S','T','J','C','P','D','Z'};
   char social[][12]= {"164-55-0726","948-44-1038","193-74-0274","458-57-2867","093-50-1093","159-56-9731","695-21-2340","753-66-6482","852-73-4196","648-81-1456","879-61-1829","123-87-6431","248-65-3197","741-85-9632","963-25-7418"};

   int n = sizeof(social)/(sizeof(social[0]));       // calculate total number of patients by using social array
   for(int i=0;i<n;i++)
   {
       // print the each patient's first name, last name, middle initial, ssn without encrypted and encrypted ssn
       printf("%s %s %c, SS# = %s, Encrypted SS# = ",fName[i],lName[i],middleInitial[i],social[i]);  
       for(int j=0;social[i][j]!='\0';j++)
       {
           if(social[i][j]=='-')
           {
               printf("-");   // if the character is not a digit just print it
           }
           else
           {
               int value = (social[i][j]-48)+65;   // convert the digits to it's equivalent letter
               printf("%c",value);           // print each letter
           }
       }
       printf("\n\n");
   }
}

Sample Input/Output

Add a comment
Know the answer?
Add Answer to:
**** C language **** Given are the variables: Lastname, Firstname, Middle Initial and their SSN. char...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PYTHON The program needs to process the arrival and departure of each patient documented in the...

    PYTHON The program needs to process the arrival and departure of each patient documented in the patient data file. While processing each patient, send the following output to an output file: a.Use your two new functions to initially print out a "0". b. As each patient arrives, print out the name of the patient & the time that they arrive at. c. Update the billboard counter to indicate that the wait time has increased. d. Print out the new billboard...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT