import java.util.Scanner;
public class WordCount {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
String sentence=new String();
System.out.println("Enter your sentence:");
sentence=sc.nextLine();
if(/*sentence=="" && sentence.length()==0*/sentence.isEmpty()){
int wCount1=0;
System.out.println("Your sentence contains "+wCount1+" words");
}else{
sentence=sentence.trim();
int wCount2=0;
for(int i=0;i
Comments
Post a Comment