Hidy ho everyone,
I found this code on how to break apart a number and store it in an array online. Quite frankly, I still don't understand how it works.
int input = Integer.parseInt(JOptionPane.showInputDialog("Please enter a 4 digit number")); int[] numbers; numbers = new int[4]; for (int i = 3; i > -1; i--) { numbers[i] = (input % 10); input = input /10; }
now I'm using this code again in another homework program where the user has to input a 4 digit number and I have to break that number apart. This program is about encryption.
What I have to do is replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10. Then swap the first digit with the third, and swap the second digit with the fourth. Then print the encrypted integer (copied and pasted from my ebook text).
now I can add 7 to everything in the array, but I don't understand what its asking me to do with getting the remainder after dividing by 10. That's where I'm having my difficulty.