Leave a comment

Comments 7

pooh27bear January 15 2009, 18:42:24 UTC
What if one uses commas or periods?

So if I inputed 99,999,999,999,999 or 7.777.777.777 or 5,555,555,555.555?

Reply

pooh27bear January 15 2009, 18:43:00 UTC
Or if I inputed non numeric?

Reply

matt_arnold January 15 2009, 18:45:59 UTC
It throws an exception because it is looking for a value of type "long", which is an integer.

Reply


Style anonymous January 15 2009, 21:07:29 UTC
A comment on style: most professional programmers would prefer that you not comment every line of code. If it's obvious what is going on (like in your println statements) you shouldn't add a comment. The comments about the division are probably fine, for example, since the code can be cryptic by itself.

Of course, if your teacher wants you to comment every line, by all means do it.

Reply

Re: Style matt_arnold January 16 2009, 01:39:49 UTC
Thanks for your advice! Once I'm done with learning exercises, I will definitely do as you describe; but until I am confident that I will remember what System.out.println means, I will comment it as a study aid. My instructor does prefer more comments over less as a general rule.

Reply

Re: Style loop_bell January 16 2009, 14:55:32 UTC
Along those lines, once you do remember what those are for, try to focus your comments osn why you are doing something rather than just what you are doing. Nothing is worse that reading code like this:

// add x and y to get the total
total = (x*y) + z;

Something changed -- it probably used to be just x+y -- but now the comments are out of date and likely worse than no comments at all.

Reply

Re: Style matt_arnold January 16 2009, 15:20:13 UTC
That's a very good point. Thanks!

Reply


Leave a comment

Up