Removing the vowels from a sentence.
★☆☆Disemvowelling is removing all the vowels from a piece of alphabetic text. It was once a common feature of the SMS language where the number of characters in a message was limited, and users were charged per message. It requires little cognitive effort to read so it was a good way of typing message quickly and keeping the cost down. Disemvowelling has more recently been used as a forum moderation tool.
Write a program that allows the user to enter a sentence before outputting that sentence with all the vowels removed.
Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.
dvowel that:message that is the string to process.dvowel function is called.Enter the message:
Hello world
The disemvoweled version of the message is:
Hll wrld
Enter the message:
The quick brown fox jumps over the lazy dog
The disemvoweled version of the message is:
Th qck brwn fx jmps vr th lzy dg
// Disemvowel program
using System;
class Submission
{
---
// -------------------------
// Subprograms
// -------------------------
// Remove the vowels from a message
---
static string dvowel(string message)
{
---
string dvowelled = message.Replace("a", "");
---
dvowelled = dvowelled.Replace("A", "");
dvowelled = dvowelled.Replace("e", "");
dvowelled = dvowelled.Replace("E", "");
dvowelled = dvowelled.Replace("i", "");
dvowelled = dvowelled.Replace("I", "");
dvowelled = dvowelled.Replace("o", "");
dvowelled = dvowelled.Replace("O", "");
dvowelled = dvowelled.Replace("u", "");
dvowelled = dvowelled.Replace("U", "");
---
return dvowelled;
---
}
---
// -------------------------
// Main program
// -------------------------
public static void Main(string[] args)
{
---
Console.WriteLine("Enter the message: ");
string message = Console.ReadLine();
---
Console.WriteLine("The disemvoweled version of the message is:");
---
Console.WriteLine(dvowel(message));
---
}
---
}
// Disemvowel program
using System;
class Submission
{
---
// -------------------------
// Subprograms
// -------------------------
// Remove the vowels from a message
---
static string dvowel(string message)
{
---
string dvowelled = "";
---
// Consider each character
foreach (char c in message)
{
---
// Only add the character to the message if it is not a vowel
if (!"AaEeIiOoUu".Contains(c))
{
---
dvowelled += c;
---
}
---
}
---
return dvowelled;
---
}
---
// -------------------------
// Main program
// -------------------------
public static void Main(string[] args)
{
---
Console.WriteLine("Enter the message: ");
string message = Console.ReadLine();
Console.WriteLine("The disemvoweled version of the message is:");
Console.WriteLine(dvowel(message));
---
}
---
}