Posted By:
Joshua_Jones
Posted On:
Friday, December 3, 2010 03:40 PM
My code should be counting words via spaces, new lines, and certain punctuations, but my if statement is not catching properly. Please help. for(int c = 0; c <= (words.length() - 1); c++) { character = wordCounter.read(); replacementChar = character; if(c == 0) oldChar = character; System.out.println(character); //This will equal 32 System.out.println(oldChar); //This will equal 46 if((character == 32 || character == 33 || character == 46 || character == 47 || character == 63) && (oldChar != 32 || oldChar != 33 || oldChar != 46 || oldChar != 47 || oldChar != 63)) wordCount++; oldCh
More>>
My code should be counting words via spaces, new lines, and certain punctuations, but my if statement is not catching properly. Please help.
for(int c = 0; c
<= (words.length() - 1); c++) {
character = wordCounter.read();
replacementChar = character;
if(c == 0)
oldChar = character;
System.out.println(character); //This will equal 32
System.out.println(oldChar); //This will equal 46
if((character == 32 || character == 33 || character == 46 || character == 47 || character == 63) &&
(oldChar != 32 || oldChar != 33 || oldChar != 46 || oldChar != 47 || oldChar != 63))
wordCount++;
oldChar = replacementChar;
}
<<Less