String Method (Beginners) - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

String Method (Beginners)

DiegomeisterDiegomeister Posts: 2Member
import javax.swing.JOptionPane;
public class wordtrimer
{
public static void main(String [] args)
{
String word = JOptionPane.showInputDialog(null,"Enter a sentence");
word = word.trim();
String aCharachter;
int wordCounter = 0;
double cost;

for (int counter = 0; counter <= word.length() -1;
counter++)
{
aCharacter = word.substring(counter,counter++);
if (aCharacter.equals(""))
wordCounter++;
}
cost = (wordCount + 1) * .05;
if ((word.substring(counter.counter++)).equals(""))
wordCounter++;

JOptionPane.showMessageDialog(null,word);
}
}
Sign In or Register to comment.