Nevermind. It turns out it worked. The only thing wrong with it is my lack of patience.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Nevermind. It turns out it worked. The only thing wrong with it is my lack of patience.
Last edited by hjen; October 20th, 2010 at 08:28 AM.
I assume you mean by defining a new string as Character.toString(d). That doesn't work either though. If you mean something different, then please elaborate. I have roughly one week of programming experience, so I apologize if I seem a little dim on the subject.
Well, I've found that it can work the way you did it. However, maybe something is being defined inside one of your loops that should be defined outside, as its value is getting lost before you return the final value, hence returning "";
Well, char d may be getting lost. Not sure.
Anyway, I thought the syntax would be
char d = '0';
Otherwise you're setting it to an int. I admit I've never user BufferWriters and readers before.
Last edited by javapenguin; October 19th, 2010 at 06:28 PM.
int c = input.charAt(i);
Probably should be
int c = (int) input.charAt(i);
Otherwise you're setting an int to a char value.
And I don't mean that it'll do that. It can't, but you're telling it to anyway.
By any chance was the encrypted value you passed it empty?
Last edited by javapenguin; October 19th, 2010 at 06:36 PM.
d = (char) ((c+key-97)%26+97);
Will add c to key and then subtract 97.
Will then divide value in parenthesis by 26 and add 97 to the remainder of that division and then make the whole thing into a char.
If I add the line "System.out.println(decrypt);" right after the line "decrypt = decrypt + d" it actually prints out the right thing, but it does it over and over again in sort of an endless loop. Either way it's correct, except for the fact that it wont return the value. It seems like the return statement is unaware of what's going on inside the 'for' statement. And of course I can't move the return statement up, because then it wont compile because of "missing return statement".