Gostaria que vcs me ajudassem a resolver esse exercício
Esse exercício é de um nº criptografado.
porém, os dois últimos nº eu já consegui decifrá=lo sem problemas.
O primeiro e o segundo, não consegui, porque no exercicio o primeiro recebe o terceiro e o segundo recebe o quarto, entendeu…???
Segue a seguir o código
//Exercício 4.31a
import javax.swing.*;
public class Ex31a{
public static void main( String args [ ] ){
String a;
int x;
int x1, x2, x3, x4, in=0, in2=0, in3=0, in4=0;
int decrip;
a = JOptionPane.showInputDialog( "Digite um nº criptografado de 4 dígitos: ");
x = Integer.parseInt( a );
x1 = 0;
x2 = 0;
x3 = 0;
x4 = 0;
x1 = (x / 1000 );
x2 = (( x % 1000 ) / 100 );
x3 = ((( x % 1000 ) % 100) / 10);
x4 = (((( x % 1000 ) % 100 ) % 10) / 1);
if ( x1 == 8 )
in = 1;
else
if ( x1 == 9 )
in = 2;
else
if ( x1 == 0)
in = 3;
else
if ( x1 == 1)
in = 4;
else
if ( x1 == 2 )
in = 5;
else
if ( x1 == 3 )
in = 6;
else
if ( x1 == 4)
in = 7;
else
if ( x1 == 5 )
in = 8;
else
if ( x1 == 6 )
in = 9;
if ( x2 == 8 )
in2 = 1;
else
if ( x2 == 9 )
in2 = 2;
else
if ( x2 == 0)
in2 = 3;
else
if ( x2 == 1)
in2 = 4;
else
if ( x2 == 2 )
in2 = 5;
else
if ( x2 == 3 )
in2 = 6;
else
if ( x2 == 4)
in2 = 7;
else
if ( x2 == 5 )
in2 = 8;
else
if ( x2 == 6 )
in2 = 9;
if ( x3 == 8 )
in3 = 1;
else
if ( x3 == 9 )
in3 = 2;
else
if ( x3 == 0)
in3 = 3;
else
if ( x3 == 1)
in3= 4;
else
if ( x3 == 2 )
in3= 5;
else
if ( x3 == 3 )
in3 = 6;
else
if ( x3 == 4)
in3 = 7;
else
if ( x3 == 5 )
in3 = 8;
else
if ( x3 == 6 )
in3= 9;
if ( x4 == 8 )
in4 = 1;
else
if ( x4 == 9 )
in4 = 2;
else
if ( x4 == 0)
in4 = 3;
else
if ( x4 == 1)
in4 = 4;
else
if ( x4 == 2 )
in4 = 5;
else
if ( x4 == 3 )
in4= 6;
else
if ( x4 == 4)
in4 = 7;
else
if ( x4 == 5 )
in4 = 8;
else
if ( x4 == 6 )
in4 = 9,,,,,,
JOptionPane.showMessageDialog( null,
"O nº é: " + in + " " + in2 + " " + in3 + " " + in4);
}
}
Por favor, me ajudem