merxais
03-16-2005, 12:42 AM
/*
A company who wants to transmit data over the telephone, but they are concerned that their phones are trapped. All of their data transmitted as four digit integers. They have asked you to write a program that will encrypt their data so that it may be transmitted more securely. Your application should read a four digit integer entered by the user in an input dialog and encrypt it as follows: Replace each digit by the sum of that digit plus 7 modulus 10. The swap the first digit with the third, and swap the second digit with the fourth. Then print the encrypted integer.
*/
import javax.swing.*;
class encrypt
{
public static void main(String args[])
{
int x;
int n = Integer.parseInt(JOptionPane.showInputDialog("Enter 4 digit password:"));
while(n>0)
{
x=n%10;
n=n/10;
int a[] = new int[x];
int sum;
for(int i=0; i<=3;i++)
{
sum=(a[i]+7)%10;
for(int j=i+2;j<=3;j++)
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
JOptionPane.showMessageDialog(null,sum);
System.exit(0);
}
}
i cant make it :( anyone help pls
A company who wants to transmit data over the telephone, but they are concerned that their phones are trapped. All of their data transmitted as four digit integers. They have asked you to write a program that will encrypt their data so that it may be transmitted more securely. Your application should read a four digit integer entered by the user in an input dialog and encrypt it as follows: Replace each digit by the sum of that digit plus 7 modulus 10. The swap the first digit with the third, and swap the second digit with the fourth. Then print the encrypted integer.
*/
import javax.swing.*;
class encrypt
{
public static void main(String args[])
{
int x;
int n = Integer.parseInt(JOptionPane.showInputDialog("Enter 4 digit password:"));
while(n>0)
{
x=n%10;
n=n/10;
int a[] = new int[x];
int sum;
for(int i=0; i<=3;i++)
{
sum=(a[i]+7)%10;
for(int j=i+2;j<=3;j++)
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
JOptionPane.showMessageDialog(null,sum);
System.exit(0);
}
}
i cant make it :( anyone help pls