wood burning stoves*
The moose likes Beginning Java and the fly likes Program is <-- Edited Question" title="" /> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Program is "passing over" a line? <-- Edited Question" Watch "Program is "passing over" a line? <-- Edited Question" New topic
Author

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

Ashley Kin
Ranch Hand

Joined: Oct 18, 2011
Posts: 36
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!

Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
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

Joined: Oct 18, 2011
Posts: 36
Yes, thank you, that worked very well!
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

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. :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Program is "passing over" a line? <-- Edited Question