Write a Java program that prompts the user to enter 5 digit number n and a digit key k and encrypts?
... the number as follows: Every digit of n is replaced by the remainder of this digit when divided by k. Then add to the resulting new digit 1 if it
... the number as follows: Every digit of n is replaced by the remainder of this digit when divided by k. Then add to the resulting new digit 1 if it is the ones digit, 2 if it is the tens digit, 3 if it is the hundreds digit and so forth. Your program should then display the resulting number.
For example, if the user enter 47921 as n and 3 as the key, then the new integer is formed of the following digits:
(1 % 3) + 1 2
(2 % 3) + 2 4
(9 % 3) + 3 3
(7 % 3) + 4 5
(4 % 3) + 5 6
Sample Run 1:
Enter a 5 digit number: 47921
Enter a key: 3
The resulting number is: 65342
Sample Run 2:
Enter a 5 digit number: 86432
Enter a key: 5
The resulting number is: 85753
or:... the number as follows: Every digit of n is replaced by the remainder of this digit when divided by k. Then add to the resulting new digit 1 if it is the ones digit, 2 if it is the tens digit, 3 if it is the hundreds digit and so forth. Your program should then display the resulting number.For example, if the user enter 47921 as n and 3 as the key, then the new integer is formed of the following digits:(1 % 3) + 1 \uf0e0 2(2 % 3) + 2 \uf0e0 4(9 % 3) + 3 \uf0e0 3(7 % 3) + 4 \uf0e0 5(4 % 3) + 5 \uf0e0 6Sample Run 1:Enter a 5 digit number: 47921Enter a key: 3The resulting number is: 65342Sample Run 2:Enter a 5 digit number: 86432Enter a key: 5The resulting number is: 85753
Tags:write,