Do this when you receive the paper.
Write a program that extracts the words in a given sentence and
prints them using one line per word but backwards. The
input is a String (a line of text entered by the user).
Feel free to use ConsoleReader to read lines from the user.
Here's how your program might work:
Feel free to usefrilled.cs.indiana.edu%java One Type> I am here. here. am I Type> Oh, boy! boy! Oh, Type> I really like this program. program. this like really I Type> done frilled.cs.indiana.edu%
StringTokenizer to collect the words. You can if you want turn in additional materials such as: pseudocode, flow charts, additional explanations of the code and/or the approach chosen. Be sure to solve as much as you can and to turn in a program in OnCourse at the end of the lab in addition to turning in the paper with your exam.
Good luck and do well.
import java.util.*;
class One {
public static void main(String[] args) {
ConsoleReader c = new ConsoleReader(System.in);
String line;
System.out.print("Type> ");
line = c.readLine();
while (! line.equals("done")) {
StringTokenizer st = new StringTokenizer(line);
String result = "";
while (st.hasMoreTokens()) {
String token = st.nextToken();
result = token + "\n" + result;
}
System.out.print(result);
System.out.print("Type> ");
line = c.readLine();
}
}
}