hi all,, i really don`t know what its wrong in my code ,,,
what i want its the user print the sentence and the program count eash sentence and devide it here is my code,,hope u help me :)
import javax.swing.*;
public class tracing {
public static void main(String args[])
{
String s = JOptionPane.showInputDialog("Please enter a sentence");
int length=s.length();
int count = 0;
while(s.charAt(count) != ' ' )
{
count++;
}
String word1;
word1=s.substring(0, count-1);
count++;
while(s.charAt(count) != ' ' )
{
count++;
}
String word2;
int i2=count;
word2=s.substring(i2, count-1);
count++;
while(s.charAt(count) != ' ' )
{
count++;
}
String word3;
int i3=count;
word3=s.substring(i3, length-1);
System.out.println(word1 +" + "+ word2 +" +"+ word3);
}
}// end class