I've just received my nitpick for assignment 4b. One of the things that was mentioned was that I should consider printing the number as I go along... rather than what I had been doing, which was saving the number in a String variable.
But I did this for 2 reasons: 1. I thought that just working with a variable, and printing the number once, would be much more efficient than sending several print statements thoughout the processing. Am I wrong? 2. By using a variable, I could determine when/where I should place a comma separating some of the words (i.e. if there's already text in the variable, and I want to add more text, add a comma first).
So, can somebody tell me why it makes more sense to print the number as you go along?
Thanks Pauline. That was an extremely informative discussion.
That addresses reason number 1 above, but not reason number 2. Is there a recommeded way to deal with determining if you've already printed something (for the purposes of printing the comma)? or do you not care about commas in Assignment 4b?
I guess I could create another variable (probably boolean) which would indicate if anything has been printed. Is that the way to do it?
Joined: Jan 19, 2001
The short and easy-way-out answer: strictly speaking, commas aren't really required. But you can work them in if you want to.
When I did the search for the concat discussion I came across a couple other old chats about the comma too. I've only got a minute now, so I can't go get them, but maybe you can come up with them. A search using "comma" and "say" should do the trick.