Computer Science Canada 2 <= base <= 16 converter. |
Author: | MysticVegeta [ Sun Feb 26, 2006 12:44 pm ] | ||
Post subject: | 2 <= base <= 16 converter. | ||
My apologies for being a noob at math. I dont know how to directly convert bases so I go from currentBase to 10 to desiredBase. The code is straight for ward. The input file is attached. Its format is: Number numsBase theBaseYouWantIn Just changing the variable numberOfInputs would make it read how many linesyou want it to.
PS: I know tis a noobie submission, but its my first sub. in java =\ |
Author: | mckhatri1 [ Wed Jul 05, 2006 8:22 am ] | ||
Post subject: | Easier Way | ||
Mind if I help simplify:
|
Author: | Krabjuice [ Wed Jul 05, 2006 10:21 am ] |
Post subject: | |
How about this? Make sure you download both classes. |
Author: | wtd [ Wed Jul 05, 2006 11:52 am ] | ||||
Post subject: | |||||
Your indentation is all wrong. You're putting starting braces on their own lines. You have spaces between open parens and class names as well as in method calls in places. You have spaces between array names and subscripts. You sometimes use cryptic variable names like "po". You lack proper spacing around some operators. Now, non-style issues.
If the string is empty, charAt(0) will throw an exception. You don't catch this, so the end result is that your program will die horribly. If we reverse the two conditions, then short-circuiting saves your bacon.
Oh, and use methods. This much functionality should not be directly in main. ![]() |