Saturday, 28 September 2013

I need help on my java program

I need help on my java program

import java.util.Scanner;
public class WordLines {
public static void main(String [] args) {
Scanner sca = new Scanner(System.in);
System.out.println("Enter a sentence");
String s = sca.nextLine();
int count = 0;
for(int j=0; j<s.length(); j++)
System.out.println(s.charAt(j));
}
}
I am trying to write a program that reads certain line from user input and
then displays only one word from than sentence to new line at a time.
For example
Input: The hill is very-steep!!
It would print out
The
hill
is
very-steep!!
So far I have done this much!!

No comments:

Post a Comment