• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Program is "passing over" a line? <-- Edited Question

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For some reason, my program is skipping over the first prompt to the user to type in a word.
For examples, it simply goes like this:

Please type an adjective: Please type a plural noun:

Everything else works fine, it's just passing over the first line or something.
Any help is appreciated, thanks!

 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So many lessons here...

I think you have the right idea with your 'v' and 'q' options -- I think you can carry that for the 'c' option; if I do that to your current code, it looks like this (I did reformat some):

Now that this code is so short, it is easier to see a problem with it. I think you wanted to get an option, perform it, and then loop back for another option. But there's no loop there. Even though the wasn't very long, it was harder to see this before.

I do not know what you meant when you said you had trouble "initializing" for what I've called "createFile()"; the code I've replaced with that call is the following:

If I'm interpreting things correctly, it creates a PrintStream, a Scanner, and a Console that are passed into readInput; that routine reads from one file and the console and outputs to another file. Without a better understanding of why you can't put this block of code into its own routine, I am not sure how to help with that.

By the way, you are almost certainly going to have to catch some exceptions for the File constructor calls.

Is this what you were after?

rc
 
Ashley Kin
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, thank you, that worked very well!
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ashley Kin wrote:For some reason, my program is skipping over the first prompt to the user to type in a word.



Ralph mentioned a few lessons. One I didn't see addressed is (IMHO) at least as important as the rest: Your program is doing exactly what you told it to do. It it's "skipping" something, it's because you told it to do so. If you think otherwise when you see unexpected behavior, you will end up wasting lots of time and creating much frustration for yourself. :-)
 
reply
    Bookmark Topic Watch Topic
  • New Topic