private int uppercaseConsonants;
private int lowercaseConsonants;
private int uppercaseVowels;
private int lowercaseVowels;
private int numberOfVowels;
this.uppercaseConsonants = 0;
this.lowercaseConsonants = 0;
this.uppercaseVowels = 0;
this.lowercaseVowels = 0;
for (int i = 0; i < this.str.Length; i++)
if (this.str[i] >= 'A' && this.str[i] <= 'Z')
if (this.str[i] != 'A' && this.str[i] != 'E' && this.str[i] != 'I' && this.str[i] != 'O' && this.str[i] != 'U')
this.uppercaseConsonants++;
else if (this.str[i] >= 'a' && this.str[i] <= 'z')
if (this.str[i] != 'a' && this.str[i] != 'e' && this.str[i] != 'i' && this.str[i] != 'o' && this.str[i] != 'u')
this.lowercaseConsonants++;
if (this.str[i] >= 'A' && this.str[i] <= 'Z')
if (this.str[i] == 'A' || this.str[i] == 'E' || this.str[i] == 'I' || this.str[i] == 'O' || this.str[i] == 'U')
else if (this.str[i] >= 'a' && this.str[i] <= 'z')
if (this.str[i] == 'a' || this.str[i] == 'e' || this.str[i] == 'i' || this.str[i] == 'o' || this.str[i] == 'u')
public void setString(string str)
public int getUppercaseConsonants()
return this.uppercaseConsonants;
public int getLowercaseConsonants()
return this.lowercaseConsonants;
public int getUppercaseVowels()
return this.uppercaseVowels;
public int getLowercaseVowels()
return this.lowercaseVowels;
public int getNumberOfVowels()
return this.numberOfVowels;
public static void Main(string[] args)
String str = new String();
Console.WriteLine("Enter any string: ");
str.setString(Console.ReadLine());
Console.WriteLine("Uppercase Consonants = " + str.getUppercaseConsonants());
Console.WriteLine("Lowercase Consonants = " + str.getLowercaseConsonants());
Console.WriteLine("Uppercase Vowels = " + str.getUppercaseVowels());
Console.WriteLine("Lowercase Vowels = " + str.getLowercaseVowels());
Console.WriteLine("Number of vowels = " + str.getNumberOfVowels());