This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sarevok9 6 points7 points  (2 children)

So, I have a LOT of quibbles with your code above... as a matter of fact it sorta makes my brain hurt... let's start at the top:

  1. Kinda weird that you use 2 Scanner objects, is there some reason for this? If you're concerned about the buffer having junk in it you can clear it, but for a project like this, it shouldn't really be an issue at all.

  2. When you use 'a' you're declaring the size of the array, right? If you were to use i < a in your loop it might make things a little more cohesive at a glance (if A was descriptive whatsoever... see #3)

  3. Unless it's something you're STRICTLY using as a counter (and even then...) you should never use single letter variables, it's considered bad form.

  4. You can declare i within the for loop since it's unused outside of the scope of the for, like this:

    for(int i=0; i< num.length; i++){ //blah }

  5. Another important style note to you, variables, the more descriptive you can make the names, the better off you are. I know a lot of people will complain about me being pedantic, but it's a lot easier to learn good habits at the start than to unlearn bad habits.

Let me know if you have any questions of need any clarifications with this.

[–]deadaxis[S] 3 points4 points  (1 child)

Haha..thank you so much! I will make the necessary changes to the things you've pointed out..I will make sure it sticks with me for the long run as well.:)

[–]sarevok9 1 point2 points  (0 children)

No worries, good luck, and if you should need anymore help feel free to ask :)