Encrypting digit

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PeyYang
    New Member
    • Mar 2007
    • 2

    Encrypting digit

    Hi

    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.prin tln("i is " + i);
    System.out.prin tln("j is " + j);

    int k = i % j;
    System.out.prin tln("i%j is " + k)
    }
    }

    but these code not fix with what the question ask.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Get your digit, convert it into a string and create an array of digits first.

    Comment

    • PeyYang
      New Member
      • Mar 2007
      • 2

      #3
      How the code look like?

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by PeyYang
        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.

        Comment

        Working...