Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question regarding Assignment 4b

 
Scott Rumrill
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Scott
 
Pauline McNamara
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Scott, I'm going to be lazy and give you a link to a couple conversations that we had on this a while ago. Fun discussions... to concatenate or not to concatenate
 
Scott Rumrill
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Scott
 
Pauline McNamara
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Enjoy And let us know what you come up with.

ciao,
Pauline
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic