A few days ago I posted a little program that would check for vowels within a given word. I have rewritten this program, it can only find vowels in the English language still but, it will now tell you each vowel that is contained in your word, along with a count of how many vowels there are total, it's still not very exciting but I would like some more feedback on what I've done, anything will help:
using System;
using System.Linq;
namespace CheckForVowels
{
class Vowels
{
static string say(string input)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(input);
return input;
}
static string prompt(string input)
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write($"{input}: ");
return input;
}
static void Main(string[] args)
{
say("We will be checking your input to see if it contains vowels or not");
prompt("Enter a word");
var count = 0;
var vowels = Console.ReadLine()
.Where(c => "aeiouAEIOU".Contains(c))
.Distinct();
foreach (var vowel in vowels)
{
count += 1;
say($"Your word contains vowel: {vowel}.");
}
say($"You have a total of {count} vowels in your word.");
if (!vowels.Any())
say($"Your word contains no vowels.");
}
}
}
write
you stay on the same line, so when youreadline
I think it will read the entire line with theprompt
string \$\endgroup\$