We are meant to define a data dictionary and the encoding/decoding logic in flowchart format for this
Question:
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.
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?
#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 :)
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill