quantity of words
package com.gmail.vhrushyn;
import java.util.Scanner;
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("enter String");
String s = sc.nextLine();
System.out.println("quantity of words is "+ count(s));
sc.close();
}
static int count(String a) {
String[] t = a.split("[ ]");
// without "." "," "!" and "?" 'cos they make new array cells with spaces which make another cells themselves.
int c = t.length;
return c;
}
}