Your error lies in the following code:
while (!phrase.equals("quit"))
phrase = scan.nextLine();
This reads lines but only saves the last line in phrase. Each time it overwrites the last line with the new line. Also, your loop is stopping too late. It includes quit as a phrase.
The correct code would be
//loop
while (true)
{ [INDENT]//read a line
String line=scan.nextLine();
//if its quit stop right now
if(line.equals("quit"))
break;
else
//ADD the line to the phrase
phrase += line;[/INDENT]}
For more help, www.NeedProgrammingHelp.com
NPH
Junior Poster in Training
55 posts since May 2005
Reputation Points: 10
Solved Threads: 1
How did you ever find this 6 year old thread to revive?
NormR1
Posting Expert
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656