469,645 Members | 1,530 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Encrypting digit


This spring I'm taking a Java coures and I need some help if posseble.

I have this assignment and he needs me to use the modulus in the code:

Q: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. Write a separate application that inputs an encrypted four-digit integer and decrypts it to form the original number.

This is what I came up with:

public class Assignment1 {

public static void main(String[] args){
int i = 10;
int j = 3;

System.out.println("i is " + i);
System.out.println("j is " + j);

int k = i % j;
System.out.println("i%j is " + k)

but these code not fix with what the question ask.
Mar 20 '07 #1
3 2026
13,262 8TB
Get your digit, convert it into a string and create an array of digits first.
Mar 20 '07 #2
How the code look like?
Mar 21 '07 #3
13,262 8TB
How the code look like?
The code for which part? Remember you are supposed to do this not me.
It's not very hard just get your steps in order on a pice of paper first.
Mar 21 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by steve | last post: by
3 posts views Thread by Piotr | last post: by
1 post views Thread by jimfortune | last post: by
7 posts views Thread by Richard L Rosenheim | last post: by
17 posts views Thread by Kermit Piper | last post: by
3 posts views Thread by Kermit Piper | last post: by
2 posts views Thread by SeeSharp Bint | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.