Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help compling the following project into C++ Visual Studio. The encryptio

ID: 3870038 • Letter: I

Question

I need help compling the following project into C++ Visual Studio.

The encryption program gives the user several choices for encrypting (or decrypting) the uppercase characters in a file. All non-uppercase letters are simply echoed. The encryption is only performed on uppercase characters.

Choice 1 – No encryption, echo all characters in the file

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 statement.Do not use any if’s, switch’s, loop’s for this part of the conversion.

Choice 3 – Duplicate every other letter.For example, “ABCD” becomes “AABCCD”.

Choice 4 – This will calculate a hash value.You will 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 98 because ‘A’ is 65, ‘B’ is 66, ‘C’ is 67, which has a sum of 198.

Choice 5 – 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 should be accomplished without if’s, switch’s, and loop’s.

Choice 6 – This is the opposite of choice 3.Change “AABCCD” back to “ABCD”.

Your program should prompt the user for:

The encryption type

The name of a file containing your message

Your program should output the encrypted message.

file1.txt has the following contents:

AAB CC

XYYZ

Sample Run #1: (the highlighted text is what the user types)

1 - No encrypt

2 - Shift 3 forward

3 - Double every other

4 - Find hash

5 - Shift 3 backward

6 - Remove characters

Choice? 1

Filename? file1.txt

AAB CC

XYYZ

Sample Run #2: (the highlighted text is what the user types)

1 - No encrypt

2 - Shift 3 forward

3 - Double every other

4 - Find hash

5 - Shift 3 backward

6 - Remove characters

Choice? 2

Filename? file1.txt

DDE FF

ABBC

Sample Run #3: (the highlighted text is what the user types)

1 - No encrypt

2 - Shift 3 forward

3 - Double every other

4 - Find hash

5 - Shift 3 backward

6 - Remove characters

Choice? 3

Filename? file1.txt

AAABB CCC

XYYYZZ

Sample Run #4: (the highlighted text is what the user types)

1 - No encrypt

2 - Shift 3 forward

3 - Double every other

4 - Find hash

5 - Shift 3 backward

6 - Remove characters

Choice? 4

Filename? file1.txt

86

Sample Run #5: (the highlighted text is what the user types)

1 - No encrypt

2 - Shift 3 forward

3 - Double every other

4 - Find hash

5 - Shift 3 backward

6 - Remove characters

Choice? 5

Filename? file1.txt

XXY ZZ

UVVW

Sample Run #6: (the highlighted text is what the user types)

1 - No encrypt

2 - Shift 3 forward

3 - Double every other

4 - Find hash

5 - Shift 3 backward

6 - Remove characters

Choice? 6

Filename? file1.txt

AB C

XYZ

Additional Notes:

If c is char variable, then isupper(c) will return true if c contains an uppercase character, false otherwise

To read a single character from a file, you can use: inFile.get(c);

This will read each character, even the whitespace characters

Other Considerations:

Did you remember system(“PAUSE”)?

Did you include comments?

Sample Run #1: (the highlighted text is what the user types)

1 - No encrypt

2 - Shift 3 forward

3 - Double every other

4 - Find hash

5 - Shift 3 backward

6 - Remove characters

Choice? 1

Filename? file1.txt

AAB CC

XYYZ

Sample Run #2: (the highlighted text is what the user types)

1 - No encrypt

2 - Shift 3 forward

3 - Double every other

4 - Find hash

5 - Shift 3 backward

6 - Remove characters

Choice? 2

Filename? file1.txt

DDE FF

ABBC

Explanation / Answer

CODE FOR THE GIVEN PROGRAM FOR ALL CASES OF ENCRYPTION..

OUTPUT HAS BEEN ACHIEVED AS THE SAMPLE GIVEN ABOVE..

#include <iostream> //main header files required

#include <fstream> //header file for files input and output

using namespace std;

int main() {

ifstream fin; //for declaring file

fin.open("my-input-file.txt"); //for opening file

char s,j ; //declaring variables

int t=0,n;

int count = 0;

cout<<"1 - No encrypt "; //Giving various choices to select from

cout<<"2-shift 3 forward ";

cout<<"3 - Double every other ";

cout<<"4 - Find hash ";

cout<<"5 - Shift 3 backward ";

cout<<"6 - Remove characters ";

cout<<"Enter a character ";

switch case(n) //selecting choices

{

case1: while (!fin.eof() ) // running while loop till end of file   

{

fin.get(s); //printing characters without encryption

cout <<s;

}

case2: while (!fin.eof() )

{

fin.get(s); //getting value input

t=s+3; //shifting three places forward

j=s;

cout << j;

}

case3: while (!fin.eof() )

{

fin.get(s);

if(isupper(s)&&((count%2)!=0)) //checking for upper and for ood places to double at only every other place

{

count++;

cout<<s<<s;

}

else

cout << s;

}

case 5: while (!fin.eof() )

{

fin.get(s); //getting input

t=s-3; //shifting three places backwards

j=s;

cout << j;

}

case 6: while (!fin.eof() )

{

fin.get(s);

if(isupper(s)&&((count%2)!=0))

{

count++;

}

else

cout << s;

}

  

case 4: {

while(!fin.eof())

{

fin.get(s);

t=t+s; //sum of ascii code of all the variables

}

cout<<(t%100); //printing the last two value of sum by dividing by hundred

}

fin.close();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote