public int decrypt(int num)
	{
		int number = num; // Encrypted: 4523 Original: 5678
		int d0,d1,d2,d3;
		
		d0 = number%10; // 3
		d1 = number%100/10; // 2
		d2 = number%1000/100; // 5
 		d3 = number%10000/1000; // 4

		d0 = (d0 < 3) ? d0 % 10 - 7 : d0 = d0 % 10 + 10 % 7;
		d1 = (d1 < 3) ? d1 % 10 - 7 : d1 = d1 % 10 + 10 % 7;
		d2 = (d2 < 3) ? d2 % 10 - 7 : d2 = d2 % 10 + 10 % 7;
		d3 = (d3 < 3) ? d3 % 10 - 7 : d3 = d3 % 10 + 10 % 7;

 		String tempDecrypt = Integer.toString(d1) + Integer.toString(d0) + Integer.toString(d3) + Integer.toString(d2);
 		int decryptedNum = Integer.parseInt(tempDecrypt);
 		
		return decryptedNum;
	}

Whenever I compile my program I get the following error:

[B][uname@workstation Exercises]$ javac EncryptionDecryptionTest.java[/B]
./EncryptionDecryption.java:37: unexpected type
required: variable
found   : value
		d0 = (d0 < 3) ? d0 % 10 - 7 : d0 = d0 % 10 + 10 % 7;
		              ^
./EncryptionDecryption.java:38: unexpected type
required: variable
found   : value
		d1 = (d1 < 3) ? d1 % 10 - 7 : d1 = d1 % 10 + 10 % 7;
		              ^
./EncryptionDecryption.java:39: unexpected type
required: variable
found   : value
		d2 = (d2 < 3) ? d2 % 10 - 7 : d2 = d2 % 10 + 10 % 7;
		              ^
./EncryptionDecryption.java:40: unexpected type
required: variable
found   : value
		d3 = (d3 < 3) ? d3 % 10 - 7 : d3 = d3 % 10 + 10 % 7;
		              ^
4 errors
This is the right syntax of a one line if in java. right?
IntVariable = Condition ? Number1 - Number2 : Number1 + Number2;

if (Condition)
     IntVariable = Number1 - Number2;
else
     IntVariable = Number1 + Number2;


So why do I get the errors I mentioned above?
thx in advance.

No, it's not the right syntax. You've got an extra assignment in there. Strip out the second d0= and you should be good to go.

d0 = (d0 < 3) ? d0 % 10 - 7 : d0 = d0 % 10 + 10 % 7;

Stupid me, Copy/Paste Error, damn how could I've not seen that?

Thanks for the help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.