To the following program I need to:
Homework 2.b
/* crypto.c. Program that encrypts a letter by shifting the value
by k*/
#include <stdio.h>
#define BASE 65
#define RANGE 26
main()
{
char originalLetter;
char encryptedLetter;
int k;
printf("Input a Capital letter:\n");
scanf("%c", &originalLetter);
printf("Input an integer that is less than 26:\n");
scanf("%d", &k);
encryptedLetter = BASE+(originalLetter-BASE+k)%RANGE;/*the calculation*/
printf("The encrypted letter is %c.\n", encryptedLetter); /*Output */
}
Task 1: Modify your program for homework 2.b so that your program will not do anything when the input is not a capital letter the shifting distance is not within the range 0~25
Task 2: Modify your program again so that your program can process both capital letters and lower case letters when the input is ‘a’ and k is 4, the output should be ‘e’ when the input is ‘A’ and k is 4, the output should be ‘E’
when the input is not a letter, your program do nothing when shifting distance is not within the range 0~25, your program also do nothing.
And then;
Task 1: Upgrade your program for homework 3.a, so that: the program can encrypt all the 95 displayable characters from ‘ !’ (33) to ‘~’ (126). The shifting distance now can range from 0 to 93. The program still checks if the input character and shifting distance are within the ranges
Task 2(counter-controlled loop): Ask the user to input the total number of characters to encrypt and shifting distance. Then, read in and encrypt the
characters one by one.
Task 3(sentinel-controlled loop): Ask the user to input a shifting distance. Then, read in any number of characters and encrypt them one by one until the user inputs ‘! ’