Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We are meant to define a data dictionary and the encoding/decoding logic in flowchart format for this c++ code. The user enters a number with

We are meant to define a data dictionary and the encoding/decoding logic in flowchart format for this c++ code.

The user enters a number with characters of 2 to 8. If the number is a two digit number you swap the positions of the numbers (eg: if the number is 56, altered number is 65). 2. If the number is a three digit number, digits at positions 1 and 3 are swapped. (eg: number is 123, altered number is 321) 3. If the number is four digits or above the following rules apply. Replace the first digit by the remainder after the sum of that digit plus 1 is divided by 10, the second digit by the remainder after the sum of that digit plus 2 is divided by 10, third digit by the remainder after the sum of that digit plus 3 is divided by 10, fourth digit by the remainder after the sum of that digit plus 4 is divided by 10 and so on.image

can I have a couple of lines filled in this data table as I still don't understand it. and the encoding logic from the code in flowchart format?

image

#include //input output

#include //sleep function

using namespace std; //used for ease of typing

void encrypt(int array[], int digit) //encrypt contains integer array and (integer)

{

for(int i=0; i

{

array[i] = (array[i] + digit - i)%10; //decrypt algorithm = (number - digit - array_value) mod(%) 10

}

}

void decrypt(int array[], int digit)

{

for(int i=0; i

{

array[i] = (array[i] - digit + i + 10)%10; //encrypt algorithm = (number + digit + array_value + 10) mod(%)10

}

}

int numberOfDigit(int number)

{

int digit = 0;

while(number)

{

digit++;

number = number/10;

}

return digit;

}

int main()

{

cout<<"Enter a number of 2 to 8 digit"<

int number;

cin>>number;

int digit = numberOfDigit(number);

if(digit <2 || digit > 8)

{

cout<<"number of digit must be from 2 to 8. Exiting"<

}

int maxDigit = 8;

int array[maxDigit] ={0};

int i = digit-1;

while(number)

{

array[i] = number%10;

number = number /10;

i--;

}

cout<<"Encrypting Number: "<

encrypt(array, digit);

sleep(2);

cout<<" - ";

sleep(1);

cout<<"- ";

sleep(1);

cout<<"- ";

sleep(1);

cout<<"Encrypted number is: ";

for(int i=0; i

{

cout<

}

cout<

cout<<"Decrypting Encryption:"<

decrypt(array,digit);

sleep(2);

cout<<" - ";

sleep(1);

cout<<"- ";

sleep(1);

cout<<"- ";

sleep(1);

cout<<"Decrypted number is: ";

for(int i=0; i

{

cout<

}

cout<

}

thank you in advance :)

Position of the number is counted from right to left. 5 Position 8 9 Position 7 1 5 4 2 Position 3 3 Position 2 9 Position 1

Step by Step Solution

3.43 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

encrytion decryption DATA to be stored Sample data Type of data C type input method output ... 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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

Why should a business be socially responsible?

Answered: 1 week ago

Question

Discuss the general principles of management given by Henri Fayol

Answered: 1 week ago

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago