java A company wants to transmit data over the telephone but

java A company wants to transmit data over the telephone, but they are concerned that their phones may be tapped. All of their data is transmitted as four-digit integers. They have asked you to write a program that encrypts their data so that it may be transmitted more securely. Your program should read a four-digit integer and encrypt it as follows: Replace each digit by (the sum of that digit plus 7) modulus 10. Then swap the first digit with the third, swap the second digit with the fourth, and print the encrypted integer. Write a separate program that inputs and encrypted four-digit integer, and decrypts it to form the original number.
java A company wants to transmit data over the telephone, but they are concerned that their phones may be tapped. All of their data is transmitted as four-digit integers. They have asked you to write a program that encrypts their data so that it may be transmitted more securely. Your program should read a four-digit integer and encrypt it as follows: Replace each digit by (the sum of that digit plus 7) modulus 10. Then swap the first digit with the third, swap the second digit with the fourth, and print the encrypted integer. Write a separate program that inputs and encrypted four-digit integer, and decrypts it to form the original number.
java A company wants to transmit data over the telephone, but they are concerned that their phones may be tapped. All of their data is transmitted as four-digit integers. They have asked you to write a program that encrypts their data so that it may be transmitted more securely. Your program should read a four-digit integer and encrypt it as follows: Replace each digit by (the sum of that digit plus 7) modulus 10. Then swap the first digit with the third, swap the second digit with the fourth, and print the encrypted integer. Write a separate program that inputs and encrypted four-digit integer, and decrypts it to form the original number.

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.

 java A company wants to transmit data over the telephone, but they are concerned that their phones may be tapped. All of their data is transmitted as four-digi
 java A company wants to transmit data over the telephone, but they are concerned that their phones may be tapped. All of their data is transmitted as four-digi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site