Yes a while loop fixes the problem! Thank you so much Norm!
Type: Posts; User: eugene3204
Yes a while loop fixes the problem! Thank you so much Norm!
I found the problem now. This is the output of i and st.length()
i: 0
st.length(): 168
=================
i: 1
st.length(): 160
=================
i: 2
st.length(): 151
=================
This is my revised code:
public static void charNum(String st) {
// define variables
String first_word;
int word_length;
String longest_word = "";
int temp_wordcount = 0;...
This is just the input sentence for the code to find the longest word. The meaning of it does not matter, which you can replace it with any other sentences. This is a sentence I copied from the...
Hi Norm,
Thank you for your reply. I have added the comments below and hope it makes it more clear.
The expected output from the code is to display the longest word in sentence. The problem is that...
I am writing the following code to display the longest word in a sentence and there are bugs which I have no idea how to solve this. Please help me.
Input st = aaaa bbbb ccccc ddd eee ffff aaaa...