i have C++ Problem : ( i need acual code for this problem):
1. A palindrome is a number or a text phrase that reads the same
backwards as forwards. For example, each of the foDowing 5 digit
integers is a palindrome: 12321, 55555, 15551, 11611. Write a function
that reads a positive five digit integer and determines whether it is
a palindrome. Use the division and modulus operators to separate the
number into its individual digits. For example the first digit is
determined by:
/I determine first digit by integer division by 10000 firstDigit = number /10000;
and the second digit by:
/I determine second digit
/I first calculate last 4 digits by using mod operator
/I then use integer division by 1000 to obtain second digit
secondDigit = number % 10000/1000;
NOTE: stop looping when the user enters a negative value.
2. A company wants to transmit data over the telephone, but is
concerned with privacy. AD of the data are transmitted as four-digit
integers. You wiD write a function to encrypt the data with a simple
cipher. Create an input file that has 20, 4-digit integers. Your
function shall read each four-digit integer and encrypt it as foDows:
a. replace each digit by (the sum of that digit plus 7) modulus 10.
1. first = ( number /1000 + 7 ) % 10;
b. Swap the first digit with the third
c. Swap the second digit with the fourth
d. add components to obtain decrypted number
e. Print the encrypted integer.
f. Write the integer to a file "encrypted.txt"
3. Write another function that inputs the encrypted four-digit integer
(from file "encrypted.txt" and decrypts it to the original number.
Your function shall read a four-digit integer and decrypt it as
follows:
i. replace each digit by (the sum of that digit plus 3) modulus 10.
ii. swap first and third iii. swap second and fourth iv. add
components to obtain decrypted number v. Print the decrypted integer.
vi. Write the integer to a file "decrypted.txt" |