rite two C programs. First program (encrypt.c) executes a Caesar cipher, which used to encrypt text messages in the files. Second program (team.c) maintains information for the soccer team. Data in your team would be stored in the memory with the use of a linked list, with list nodes representing players.
A. Caesar’s Cipher for Files
prepare the C program “encrypt.c” which encrypts the message using one of an oldest known encryption techniques,called Caesar cipher, attributed to Julius Caesar. It involves replacing each letter in the message with another letter which is the fixed number of positions later in a alphabet (shift). If replacement will go past the letter Z, the cipher “wraps around” to the starting of the alphabet. like, if each letter is replaced by a letter two positions after it (shift by 2), then A will be replaced by a letter C, Y will be replaced by a letter A, and Z will be replaced by a letter B. Program must get two arguments:
(a) name of a file containing message to be encrypted and
(b) shift amount as the valid integer from 1 to 25 (inclusive).
Here’s the ex of a call to the program:
$ ./encrypt message.txt 3
Program then prepares encrypted message to new file with similar name but the added extension of .enc. In ex given above, original file name is message.txt, so encrypted message would be stored in a file named message.txt.enc.
You might suppose that:
• There is no limit on size of the file to be encrypted or on the length of each line in the file.
• Characters other than letters must be left analtered.
• Lower-case letters remain lower-case and upper-case letters remain upper-case.
Notice that program could also be used to decrypt a message if the user knows the original key by providing the encrypted message and using as shift amount 26 minus the original key. As an ex:
$ ./encrypt message.txt.enc 23
B. Linked Lists
prepare a C program “team.c” which maintains information for a soccer team. The program would permit you to add and delete players from your team, to search your team for players by name or by value they are worth, and to print out part or all of the team.
The data in your team would be stored in memory with the help of a linked list, with list nodes representing players. Each node would contain members for storing a player’s family name (char *) and first name (char *), their position (char) and their value (int). There are four possible positions, each of which is identified by the first character in the words (G)oalkeeper, (D)efender, (M)idfielder and (S)triker. Your linked list should be kept in a special order, with all goalkeepers first, then defenders, then midfielders, and at last the strikers. If there is more than one player in same position, then players must be kept in order of their insertion (e.g., the last defender in the team, must be the defender most recently inserted into the list; the first striker in the team must be the striker that was inserted first into list, and so on). You might suppose that no two players that assume the same position in your team have same family name.
Your program must be menu driven, with user being offered a choice of the six commands described below:
• Insert new player into a team. Program must prompt user for the new family name and first name, a position and a value. This information must be placed in new node that has been created using malloc function. And then node must be inserted at a suitable position in the linked list which stores the team data. Do not forget that team should be stored in special order, by considering the player’s position first, and then (if needed) the order of insertion. If the node with given family name is already in a team, an error message must be produced and new node must not be inserted into a linked list.
• Delete player from the team. Program must prompt the user for the family name of the player to be deleted and then delete node containing that family name from the linked list which stores the team. If no player with the given family name is found in the team, an error message must be produced.
• Search for the player using input family name. Program must print the family name, first name, position and value of the player, with each piece of information on a separate line. If no player with given family name is found in the team, an error message must be produced.
• Search for players in team which are worth less than or equal to an input value. Program must print family name, first name, position and value of any player which is worth less than or equal to the input value, with information of each player on the separate line. Blank line must be printed between each player (if more than one is found). If no player in team is worth less than or equal to the given value, the error message must be produced.
• Print team, following special order. Print family name, first name, position and value of each player, with each piece of information on separate line. A blank line must be printed between each player. Special order supposes that goalkeepers appear first, then defenders, then midfielders, and at last strikers. If there are more than one players of same position, then they must be printed in order of their insertion.
• Quit program. When a program is given the quit command, it must delete all nodes in linked list by using calls to free function. It must then try to print linked list.
It is suggested that you finish and test each step before moving on to next one. This way, if the program no longer works, you would know which statements are causing an error.