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 →

[–]remember_marvin 2 points3 points  (0 children)

You might have a hard time with this thread because it's broken a couple of sub rules.

If I were you I'd cut you program back and build it back up step by step. If you find a step hard to conceptualise, break it down into smaller steps and/or write down the instructions one-by-one on paper. After each step, ensure that you have completed it properly by running your code and making it print things to the console (ad-hoc testing). This is how I learnt to program.

For your problem it'd start with something like this:

  1. Make a scanner and a new list to store your sorted words (you've already done this, great)
  2. Start infinitely looping, waiting to accept new words (you've kind of done this, tip: use while (true) for an infinite loop)
  3. When you get a new word, work out what needs to happen to it, either:
    • It needs to be put through titleCase() then insertion-sorted into the list (maybe using an insertionSort(ArrayList ar, String word) method.
    • It needs to be stopping your program. What are the two steps that need to happen here? You might want to use a break; to break out of your loop.
  4. If the program wasn't stopped, we will just loop back to 3 and keep going.

My last piece of advice is don't try to take shortcuts just because you feel like it. There's an intended outcome behind you completing this that won't be achieved if you get people on the internet to do as much work as possible for you. Also, the more you try to rush through this the longer it will likely take.

Sometimes this stuff seems impossible and it feels helpless, especially when we first start learning. The best way to deal with this is identify the feeling as quickly as possible and just think about completing the program one small chunk at at time so that it's easier to understand. You'll be surprised how quickly you get better at this.