write a program in java to accept a string. Count all the letters in the string except the vowels
Answers
Answered by
3
import java.util.Scanner;
import java.io.*;
public class Test {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the sentence");
String i = scan.nextLine();
int len=i.length();
int count = 0;
for (char c: i.toCharArray()){
if(c == ' '||c == 'a' || c =='e' || c=='i' || c=='o' || c=='u' || c=='A'||c=='E' ||c=='I'||c=='O'||c=='U')
count++;
}
int let=len-count;
System.out.println("no of letters excluding vowels is "+let);
}}
Similar questions