| 4 | import java.util.Scanner; |
| 5 | |
| 6 | public class CountWords { |
| 7 | |
| 8 | public static int countWords(String str ) { |
| 9 | int count = 0; |
| 10 | for (int i = 0; i < str.length(); i++) { |
| 11 | if (str.charAt(i) == ' ') { |
| 12 | count += 1; |
| 13 | } |
| 14 | } |
| 15 | return count + 1; |
| 16 | } |
| 17 | |
| 18 | public static void main(String[] args) { |
| 19 | Scanner sc = new Scanner(System.in); |
| 20 | String str = sc.nextLine(); |
| 21 | |
| 22 | int n = countWords(str); |
| 23 | System.out.println(n); |
| 24 | } |
| 25 | } |
nothing calls this directly
no outgoing calls
no test coverage detected