Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c#! This is my code, here are the instructions Write a Windows Form Application that uses a file dialog control to allow the user to

c#!

This is my code, here are the instructions Write a Windows Form Application that uses a file dialog control to allow the user to select a file for input, processing the contents of the file as follows: 1. Converts all the words to lower-case. 2. Finds the first and last word alphabetically. 3. Finds the longest word. 4. Finds the word with the most vowels. Display the above statistics in a text box and write the above statistics to a file; include a screenshot of your program running with successful output.

The "firstWordTextBox.Text = firstWord; lastWordTextBox.Text = lastWord; longestWordTextBox.Text = longestWord; mostVowelsWordTextBox.Text = mostVowelsWord; mostVowelsCountTextBox.Text = mostVowelsCount.ToString();" is an error and doesnt work

if (openFile.ShowDialog() == DialogResult.OK)

{

string readFile;

StreamReader inputFile;

inputFile = File.OpenText(openFile.FileName);

readFile = inputFile.ReadToEnd().ToLower();

fileTextBox.Text = readFile;

// Find the first and last word alphabetically

string[] words = readFile.Split(' ');

Array.Sort(words);

string firstWord = words[0];

string lastWord = words[words.Length - 1];

// Find the longest word

string longestWord = "";

foreach (string word in words)

{

if (word.Length > longestWord.Length)

{

longestWord = word;

}

}

// Find the word with the most vowels

string mostVowelsWord = "";

int mostVowelsCount = 0;

foreach (string word in words)

{

int vowelsCount = 0;

foreach (char c in word)

{

if ("aeiou".Contains(c))

{

vowelsCount++;

}

}

if (vowelsCount > mostVowelsCount)

{

mostVowelsWord = word;

mostVowelsCount = vowelsCount;

}

}

// Display the results

firstWordTextBox.Text = firstWord;

lastWordTextBox.Text = lastWord;

longestWordTextBox.Text = longestWord;

mostVowelsWordTextBox.Text = mostVowelsWord;

mostVowelsCountTextBox.Text = mostVowelsCount.ToString();

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions