Skip to content

Instantly share code, notes, and snippets.

@ramjill
Forked from coderdan/gist:3747255
Created September 19, 2012 09:16
Show Gist options
  • Save ramjill/3748638 to your computer and use it in GitHub Desktop.
Save ramjill/3748638 to your computer and use it in GitHub Desktop.
Codehire Cup Skeleton Code for C#
public class Challenge
{
public static void Main()
{
Console.WriteLine("Enter String Name");
string inputString = Console.ReadLine();
string alphabet = new String(inputString.Where(Char.IsLetter).ToArray());
int vowel = CountVowels(alphabet);
int consonants = CountConsonants(alphabet);
Console.WriteLine("{0}vowels:{1},consonants:{2}{3}", "{", vowel, consonants, "}");
Console.Read();
}
public static int CountVowels(string value)
{
const string vowels = "aeiou";
return value.Count(chr => vowels.Contains(char.ToLowerInvariant(chr)));
}
public static int CountConsonants(string value)
{
const string vowels = "aeiou";
return value.Count(chr => !vowels.Contains(char.ToLowerInvariant(chr)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment