Code Below:


import java.util.*;
class Capital
{
    String sent;
    int freq;
    Capital()
    {
        sent="";
        freq=0;
    }
    void input()
    {
        Scanner s=new Scanner(System.in);
        System.out.println("Enter a sentence");
        sent=s.nextLine();
    }
    boolean isCap(String w)
    {
        return Character.isUpperCase(w.charAt(0));
    }
    void display()
    {
        System.out.println(sent);
        StringTokenizer st=new StringTokenizer(sent);
        while(st.hasMoreTokens())
        {
            String w=st.nextToken();
            if(isCap(w)==true)
            {
                System.out.println(w);
                freq++;
            }
        }
        System.out.println("Words starting with UpperCase = "+freq);
    }
    public static void main()
    {
        Capital obj=new Capital();
        obj.input();
        obj.display();
    }
}