This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Reversing a User's sentences. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reversing a User Watch "Reversing a User New topic
Author

Reversing a User's sentences.

sandy skiathitis
Greenhorn

Joined: Apr 22, 2011
Posts: 18
HI everyone..What I have to do it ask the user how many sentences they want to input. The give me a number and I have to reverse each sentence but it has to be like Line 1: (here would be the reverse sentence), etc all the way untill all their sentences have been reversed with the corresponding Line number. Example of the code should look like this

user input output

this is a test
 Line #1: test a is this
foobar
 
Line #2: foobar

warm up programs Line #3: programs up warm


this is what I got so far..help please






this is what shows when I run the program

run:
How many sentences are you inputing?
3
Please enter your sentences with a corresponding period(.)
I love cats. Cats rock. The cat hid under the bed.
Line1 :I
Line2 :I
Line3 :I
BUILD SUCCESSFUL (total time: 21 seconds)
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 561
Significant effort has been spent on this problem at DIC to get the code this far. Progress has stalled.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
You are using the next() method which takes the first word, delimited by whitespace. So you are reading "I" and leaving the rest of the input untouched.
By the way, you have no method shown for turning the input into an array of Strings.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reversing a User's sentences.