Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

assignments o399698 Description: This program is part 1 of a larger program. Eventually, it will have a variety of encryptions that can be applied to

image text in transcribed
image text in transcribed
image text in transcribed
assignments o399698 Description: This program is part 1 of a larger program. Eventually, it will have a variety of encryptions that can be applied to contents of a file. . For this part, the program gives the user 4 choices for encrypting (or decrypting) the first character of a file. Non- lowercase characters are simply echoed (for everything other than option #4, the hash). The encryption is only performed on lowercase characters. o If cis char variable, then islower(c) will return true if c contains an lowercase character, false otherwise o To read a single character from a file (let inFile be the name of your ifstream), you can use: inFile.get(c); This will read one character, even the whitespace characters o Choice 1 - No encryption, echo the character from the file o Choice 2 - Encrypt by shifting. For example, shifting by 3 characters would change an'a' to a'd' because that is 3 letters later. If you reach the end of the alphabet then you need to roll over. For example 'z' plus 3 is 'c NOTE: The process of converting the 'z'to a'c' should NOT need the use of an if, switch, or loop statement. . For this week, you may use an if or switch if you need, but next week you'll have to do it without o Choice 3 - This is the opposite of choice 2. Instead of moving 3 letters forward, it will move 3 letters backwards. A'd' will become'a': Like choice 2, the shifting can be accomplished without it's, switch's, and loop's. o Choice 4 - This will calculate a hash value. You sum the ASCII values of all of the characters and at the end of the file print the last 2 digits of the sum. For example, "abc" is 94 because 'a'is 97,'b' is 98, 'c' is 99, which has a sum of 294 . Remember, this week we are only reading a single character . Your program should prompt the user for: The encryption type . The name of a file . For this week, the prompt will be very short.just a ? Your program should output the encrypted characters (or a hash value). file 1.txt has the following contents: yippee file2.txt has the following contents: A-bbo cc o file2.txt has the following contents: A-bba cc 2 Sample Run #1 (bold, underlined text is what the user types): ? 1 file1.txt Sample Run #2 (bold, underlined text is what the user types): ? 2 file1.txt Sample Run #3 (bold, underlined text is what the user types): ? 3 files.txt Sample Run #4 (bold, underlined text is what the user types): ? 4 file1.txt Sample Run #5 (bold, underlined text is what the user types): ? 1 file.txt Sample Run #6 (bold, underlined text is what the user types): ? 2 file2.txt Sample Run #3 (bold, underlined text is what the user types): ? 3 filel.txt Sample Run #4 (bold, underlined text is what the user types): ? 4 file1.txt Sample Run #5 (bold, underlined text is what the user types): ? 1 file2.txt Sample Run #6 (bold, underlined text is what the user types): ? 2 file2.txt Sample Run #7 (bold, underlined text is what the user types): ? 4 file2.txt assignments o399698 Description: This program is part 1 of a larger program. Eventually, it will have a variety of encryptions that can be applied to contents of a file. . For this part, the program gives the user 4 choices for encrypting (or decrypting) the first character of a file. Non- lowercase characters are simply echoed (for everything other than option #4, the hash). The encryption is only performed on lowercase characters. o If cis char variable, then islower(c) will return true if c contains an lowercase character, false otherwise o To read a single character from a file (let inFile be the name of your ifstream), you can use: inFile.get(c); This will read one character, even the whitespace characters o Choice 1 - No encryption, echo the character from the file o Choice 2 - Encrypt by shifting. For example, shifting by 3 characters would change an'a' to a'd' because that is 3 letters later. If you reach the end of the alphabet then you need to roll over. For example 'z' plus 3 is 'c NOTE: The process of converting the 'z'to a'c' should NOT need the use of an if, switch, or loop statement. . For this week, you may use an if or switch if you need, but next week you'll have to do it without o Choice 3 - This is the opposite of choice 2. Instead of moving 3 letters forward, it will move 3 letters backwards. A'd' will become'a': Like choice 2, the shifting can be accomplished without it's, switch's, and loop's. o Choice 4 - This will calculate a hash value. You sum the ASCII values of all of the characters and at the end of the file print the last 2 digits of the sum. For example, "abc" is 94 because 'a'is 97,'b' is 98, 'c' is 99, which has a sum of 294 . Remember, this week we are only reading a single character . Your program should prompt the user for: The encryption type . The name of a file . For this week, the prompt will be very short.just a ? Your program should output the encrypted characters (or a hash value). file 1.txt has the following contents: yippee file2.txt has the following contents: A-bbo cc o file2.txt has the following contents: A-bba cc 2 Sample Run #1 (bold, underlined text is what the user types): ? 1 file1.txt Sample Run #2 (bold, underlined text is what the user types): ? 2 file1.txt Sample Run #3 (bold, underlined text is what the user types): ? 3 files.txt Sample Run #4 (bold, underlined text is what the user types): ? 4 file1.txt Sample Run #5 (bold, underlined text is what the user types): ? 1 file.txt Sample Run #6 (bold, underlined text is what the user types): ? 2 file2.txt Sample Run #3 (bold, underlined text is what the user types): ? 3 filel.txt Sample Run #4 (bold, underlined text is what the user types): ? 4 file1.txt Sample Run #5 (bold, underlined text is what the user types): ? 1 file2.txt Sample Run #6 (bold, underlined text is what the user types): ? 2 file2.txt Sample Run #7 (bold, underlined text is what the user types): ? 4 file2.txt

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

Write a JAVA program

Answered: 1 week ago

Question

understand the meaning of the terms discipline and grievance

Answered: 1 week ago