Skip to content

Instantly share code, notes, and snippets.

@sammysheep
Last active April 26, 2023 00:22
Show Gist options
  • Save sammysheep/8ccd8a8d28373635b6d073b53bc4535a to your computer and use it in GitHub Desktop.
Save sammysheep/8ccd8a8d28373635b6d073b53bc4535a to your computer and use it in GitHub Desktop.
SmithClass-VowelCount
// Vowel Count - returns the number of vowels in a document from the command line
string filename = "";
if (args.Length != 1)
{
Console.WriteLine($"\nUsage:\n\tdotnet run <filename>\n");
System.Environment.Exit(1);
}
else
{
filename = args[0];
if (!File.Exists(filename))
{
Console.WriteLine($"No file found named '{filename}'");
System.Environment.Exit(1);
}
}
var data = File.ReadAllText(filename);
// count
foreach (YOUR VARIABLE DECLARED HERE in data.ToLower())
{
// Do something to count vowels
}
Console.WriteLine($"The number of vowels in {filename} is: {count}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment