I am getting correct output but still not passing can understand why ?
package com.codegym.task.task08.task0823;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Going national
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine();
char[] sToChar = s.toCharArray();
char empty = ' ';
char stop = '.';
char[] word = new char[sToChar.length];
int count = 0;
String convertedText;
String resultWords ="";
for (char temp : sToChar) {
if (temp == empty) {
count = 0;
convertedText = new String(word);
word = new char[sToChar.length];
if (resultWords.isEmpty()) {
resultWords = convertedText.trim();
System.out.print(resultWords);
} else {
resultWords = convertedText.trim();
System.out.print(" " + resultWords);
}
} else {
if (count == 0) {
word[0] = Character.toUpperCase(temp);
} else {
word[count] = temp;
}
count++;
if (temp == stop) {
convertedText = new String(word);
if (resultWords.isEmpty()) {
resultWords = convertedText.trim();
System.out.println(resultWords);
} else {
resultWords = convertedText.trim();
System.out.print(" " + resultWords);
}
}
}
}
}
}