Computer Science, asked by SpaceWalker17, 11 months ago

Write a java program to input a statement and convert it into uppercase and count and display the total number of words starting with the letter "A" Example: Sample Input: ADVANCEMENT AND APPLICATION OF INFORMATION TECHNOLOGY ARE EVER CHANGING. Sample output: Total number of words starting with the letter 'A'=4.... please answer..(no spamming)​

Answers

Answered by Anonymous
3

Answer:

I want to write a program that count the number of words that starts with capital letters. It only count no. Of capital letter not word try this line "Hi hOw are yOu" According to my code output will be 3 But their is only 1 word that starts with capital letter that is 'Hi'...so how can I solve these problem..Please help me with this.

import java.util.*;

class Cap

{

public static void main(String m[])

{

Scanner in=new Scanner(System.in);

String s=new String();

System.out.println("Enter a line:");

s=in.nextLine();

char c;

int ct=0;

for(int i=0;i<s.length();i++)

{

c=s.charAt(i);

if(c>=65 && c<=90)

{

ct++;

}

}

System.out.println("total number of words start with capital letters are :"+ct);

}

}

Similar questions