write a Java program to input a set of 20 letters.convert each letter into upper case.find and display the number of vowel and number of consonant present in the set of given letters
Answers
Answered by
7
hey here is the program.......using string functions ,input stream reader class and my brain......this program will tell the number of constants and vowels both.....in the string inputted by user.....
Attachments:
Answered by
4
Answer:
import java.util.*;
public class Letters
{
public static void main (String args[])
{
Scanner in = new Scanner(System.in);
char ch;
int v=0,c=0,i;
System.out.println("Enter any 20 numbers");
for(i=1;i<=20;i++)
{
ch=in.next().charAt(0);
ch=Character.toUpperCase(ch);
if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
{
v++;//v=v+1
}
else if(ch>'A' && ch<='Z')
{
c++;//c=c+1
}
}
System.out.println("Number of Vowels = " + v);
System.out.println("Number of Consonants = " + c);
}
}
Similar questions