Answer to Question #124437 in C++ for Paul

Question #124437
A company wants to transmit data over the telephone, but is concerned that its phones could be tapped. All of the data are transmitted as two-digit integers. The company has asked you to write a program that encrypts the data so that it can be transmitted more securely. Your program should read a two-digit integer and encrypt it as follows: Replace each digit by (the digit plus 7) modulus 10). Then, swap the first digit with the second and print out the encrypted integer
1
Expert's answer
2020-06-29T08:15:42-0400

#include <iostream>


using namespace std;


int main()

{

int num;

//input number

cout << "Enter two-digit integer: ";

cin >> num;

//validate

if (num < 100 && num >= 10)

{

//encode

num = ((num + 7) % 10) * 10 + ((num / 10 + 7) % 10);

//print number

if (num < 10) cout << 0;

cout << num << endl;

}

//if number is not valid

else

{

cout << "Number is not valid" << endl;

}

return 0;

}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS