Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A325)Could you please help me to solve this problem? Problem: Write Standard ML

ID: 3580954 • Letter: A

Question

A325)Could you please help me to solve this problem?

Problem:

Write Standard ML function(s) to find the number of vowels and nonvowels in the strings sent as parameter in a list, and returns the strings and their count of vowels and nonvowels in a record list.

Sample Run:

-find([“good”,”luck”,”on”,”your”,”homework”]);

val it =

[{word="good",vowels=2,nonvowels=2},{ word="luck,vowels=1,nonvowels=3},

   { word="on",vowels=1,nonvowels=1},{ word="your",vowels=2,nonvowels=2 },

   { word="homework",vowels=3,nonvowels=5 }] : wrdrec list

Note:

Use the following list in your program to specify the vowels.

val vowels=[#”a”, #”e”, #”i”, #”o”, #”u”];

Use the explode function which changes a string to a char list.

- explode "abc";

   val it = [#"a",#"b",#"c"] : char list

You can write as many functions as needed.

Do not forget to declare your types.

Explanation / Answer

class Program
{
static void Main(string[] args)
{
char[] sentence = new char[] { };
int i, vowels = 0, consonants = 0, special = 0, n;
Console.WriteLine("Enter the sentence ");
string result = Console.ReadLine();
string[] result1 = result.Split(',');
foreach (string temp in result1)
{
  
for (int j = 0; j < temp.Length; j++)
{
if ((temp[j] == 'a' || temp[j] == 'e' || temp[j] == 'i' || temp[j] == 'o' || temp[j] == 'u') ||
(temp[j] == 'A' || temp[j] == 'E' || temp[j] == 'I' || temp[j] == 'O' || temp[j] == 'U'))
{
vowels = vowels + 1;
}
else
{
consonants = consonants + 1;
}
}
  
Console.WriteLine("Word={0}", temp);
Console.WriteLine("No. of vowels {0}", vowels);
Console.WriteLine("No. of consonants {0}", consonants);
//Console.ReadLine();
//Console.ReadLine();
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote