|
Sentence counter
|
|
04-03-2009, 01:04 AM
Post: #1
|
|||
|
|||
|
Sentence counter
Hi everyone-my first question on javacodez
i had to create a program that asks user to input sentences and then displays the number of sentences. Example: user input: i like clouds. i hate rocks. output: the no. of sentences are 2 so i worked on the program and this is what the main part of my code looks like: { c = new Console (); c.println ("Please enter the sentences"); String userInput; userInput=c.readLine (); String word; int punctuation=userInput.length; for (int counter=0; counter<=1; counter++) { if(userInput.equals ("?") && userInput.equals ("!") && userInput.equals (".")) { c.println ("the number of sentences are"); c.println ((counter+userInput.length ())); } } the problem: after running it and entering a sentence the code stops. i need help with correcting the part in my for loop. i will appreciate any help Thanks alot! |
|||
|
04-03-2009, 01:24 AM
Post: #2
|
|||
|
|||
|
RE: Sentence counter
Try this loop
Code: int punctuation=userInput.length(); |
|||
|
« Next Oldest | Next Newest »
|

Search
Member List
Calendar
Help




