java A company wants to transmit data over the telephone but
Solution
//This is a very basic program for Encryption of only four-digit number :-
import java.util.*;
import java.text.DecimalFormat;
public class Encrypt{
public static void main(String args[]){
System.out.println(\"Enter original word:-\");
Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
int[] array = new int[4];
int temp;
temp = input/1000;
input= input%1000;
temp = (temp + 7)%10;
array[2] = temp;
temp = input/100;
input= input%100;
temp = (temp + 7)%10;
array[3] = temp;
temp = input/10;
input = input %10;
temp = (temp + 7)%10;
array[0] = temp;
temp = input;
temp = (temp + 7)%10;
array[1] = temp;
int i=0;
String sum=\"\";
while(i<4){
sum = sum + Integer.toString(array[i]);
i++;
}
DecimalFormat decimalFormat = new DecimalFormat(\"0000\");
System.out.println(\"Encrypted word:-\"+decimalFormat.format(Integer.parseInt(sum)));
}
}
// This is a very basic program for Decryption of only four digit number :-
import java.util.*;
import java.text.DecimalFormat;
public class Decrypt{
public static void main(String args[]){
System.out.println(\"Enter Encrypted word:-\");
Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
int[] array = new int[4];
int temp;
temp = input/1000;
input= input%1000;
if(temp<7){temp = (temp+10);}
temp = (temp - 7);
array[2] = temp;
temp = input/100;
input= input%100;
if(temp<7){temp = (temp+10);}
temp = (temp - 7);
array[3] = temp;
temp = input/10;
input = input %10;
if(temp<7){temp = (temp+10);}
temp = (temp - 7);
array[0] = temp;
temp = input;
if(temp<7){temp = (temp+10);}
temp = (temp - 7);
array[1] = temp;
int i=0;
String sum=\"\";
while(i<4){
sum = sum + Integer.toString(array[i]);
i++;
}
DecimalFormat decimalFormat = new DecimalFormat(\"0000\");
System.out.println(\"original word:-\"+decimalFormat.format(Integer.parseInt(sum)));
}
}
// hope this helps and comment your response.

