wood burning stoves 2.0*
The moose likes Java in General and the fly likes Unusual behavior of Simple Cipher Program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Unusual behavior of Simple Cipher Program" Watch "Unusual behavior of Simple Cipher Program" New topic
Author

Unusual behavior of Simple Cipher Program

Vasiq Molvizadah
Ranch Hand

Joined: Dec 24, 2009
Posts: 66


If I give the input as "vasiqmz" or a word such as "x","y" then the output which I'm getting is kinda confusing....


Human Knowledge Belongs to the World.
- Vasiq Mz
Vasiq Molvizadah
Ranch Hand

Joined: Dec 24, 2009
Posts: 66

Output :
Enter the text you want to cipher.
vasiqmz
The cipher text is zewmuq(And a box symbol appears which i'm not able to print it here)

I know the reason is because of the else loop but one thing i'm not getting is..if there is no char at a given position then it should display it's value as null instead of a symbol which in case here is a box.

Any reason for that ???

Thanks for reading it....
Any comments on the program....
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What gets stored in the coded string when shift >= alphabets.length?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Also note that it's possible the text won't be encoded at all.
Vasiq Molvizadah
Ranch Hand

Joined: Dec 24, 2009
Posts: 66
David Newton wrote:What gets stored in the coded string when shift >= alphabets.length?


If the IF loop is correct then nothing gets stored in that position...If nothing gets stored then that position should contain a "null" value instead of any symbol..I mean after all the default value of char is null....
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And what would a null character print out as?
Vasiq Molvizadah
Ranch Hand

Joined: Dec 24, 2009
Posts: 66
David Newton wrote:And what would a null character print out as?


Ok i get it now....if there is nothing in that position then it'll store "'\u0000'" or "0" which is basically a null value and a null value is printed out as a box symbol....

Thanks a lot for reading the program and helping me out with the problem....David.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No problem--glad to help :)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Unusual behavior of Simple Cipher Program
 
Similar Threads
Alphabet Pyramid (this one!)
LinearProgramming in Java
A Bit Stuck!
Need help with a cipher assignment
crytography