Search:

Type: Posts; User: dianac

Search: Search took 0.27 seconds.

  1. Replies
    19
    Views
    1,882

    Re: Encrypt a text message

    No, I did not get this error. And I tried with int as well



    int n = s.length();// This is the size of the sentence

    int sqrt = (int) Math.sqrt(n);// This is the square root of number of...
  2. Replies
    19
    Views
    1,882

    Re: Encrypt a text message

    I have tried for only one input of 27 letters and it is not working. I want it to return 36 and it is returning 33, because when n gets to 33 the square root is 6 and the if test is not satisfied...
  3. Replies
    19
    Views
    1,882

    Re: Encrypt a text message

    Yes, sqrt(n) is a double, but how could I test if this double will be perfect square root if it "Returns the correctly rounded positive square root of a double value" ?
  4. Replies
    19
    Views
    1,882

    Re: Encrypt a text message

    No, the code below returns error: Syntax error on token "int", invalid Expression



    int n = s.length();// This is the size of the sentence
    if(sqrt(n)!=int){
    n++;
    }
  5. Replies
    19
    Views
    1,882

    Re: Encrypt a text message

    I did.


    public static double sqrt(double a)
    Returns the correctly rounded positive square root of a double value.

    So it always returns a rounded double. Does it mean it might round down so I...
  6. Replies
    19
    Views
    1,882

    Re: Encrypt a text message

    I wanted to write something like if squareroot of n is not an integer then increment n. But the problem is that squareroot must return a double so the way I wrote below won't work.


    ...
  7. Replies
    19
    Views
    1,882

    Re: Encrypt a text message

    Yes, I thought about this pseudocode. I just don't know the correct syntax in Java for it. How to calculate square root?
  8. Replies
    19
    Views
    1,882

    Re: Encrypt a text message

    It needs to be encypted even if the number of letters is not a square root and in this case there will be extra spaces in the box. I just don't know how to set the size of the box so it will always...
  9. Replies
    19
    Views
    1,882

    Re: Encrypt a text message

    Thanks

    The asssignment requires me to take out blank spaces first

    My main problem is how to proceed when the size is not squareroot, because the code should run for any sentence the user sets...
  10. Replies
    19
    Views
    1,882

    Encrypt a text message

    I need to write a code to encrypt any sentence in a square caesar box. So if the sentence has 28 words, the 'box'(array) should have 36 spaces. I should change s.length in my code to something that...
Results 1 to 10 of 10