Question: A company uses a public phone to transmit data. The data is a four-digit integer and encrypted during the transmission process. The encryption rules are as follows: add 5 to each number, then, replace the number with the remainder divided by 10, and then exchange the first and fourth digits, and the second and third digits.
Import Java. util. *; public class lianxi48 {public static void main (string ARGs []) {S = new partition (system. in); int num = 0, temp; do {system. out. print ("enter a four-digit positive integer:"); num = S. nextint () ;}while (Num <1000 | num> 9999); int A [] = new int [4]; A [0] = num/1000; // The number A [1] = (Num/100) % 10; // The number A [2] = (Num/10) % 10; // take the ten digits A [3] = num % 10; // take the single digit for (Int J = 0; j <4; j ++) {A [J] + = 5; A [J] % = 10 ;}for (Int J = 0; j <= 1; j ++) {temp = A [J]; A [J] = A [3-J]; A [3-J] = temp;} system. out. print ("encrypted number:"); For (Int J = 0; j <4; j ++) system. out. print (A [J]) ;}}
[Procedure 48]