using System; using static System.Console; public class SortWords { public static void Main() { SortAndDisplaywords("one"); SortAndDisplaywords("one", "two"); SortAndDisplaywords("five", "ten", "one", "two", "three"); Sort AndDisplayWords ("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"); } public static void SortAndDisplaywords (params string[] words) { } Array.Sort (words); WriteLine(string.Join("", words)); }using System; using static System.Console; public class Sortwords { public static void Main() { SortAndDisplaywords("one"); SortAndDisplaywords("one", "two"); SortAndDisplaywords("five", "ten", "one", "two", "three"); SortAndDisplaywords("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"); public static void SortAndDisplaywords (params string[] words) { Array.Sort (words); WriteLine(string.Join("", words));
in C# i need to
Write a program named SortWords that includes a method named SortAndDisplayWords that accepts any number of words, sorts them in alphabetical order, and displays the sorted words separated by spaces.
Write a Main() to test this function. The SortAndDisplayWords method will be tested with one, two, five, and ten words.
my errors are
Method
SortAndDisplayWords sorts and displays one words
Method SortAndDisplayWords sorts and displays two words
Method SortAndDisplayWords sorts and displays ten words
Method SortAndDisplayWords sorts and displays five words
Algorithm:
1. Start the program by defining the SortWords class and the Main method.
2. Within the Main method, call the SortAndDisplayWords method four times with different sets of words as arguments.
3. In the SortAndDisplayWords method, sort the words using the Array.Sort method, which sorts the elements in an array in ascending order.
4. bUse the string.Join method to concatenate the sorted words into a single string, separated by spaces.
5. Write the concatenated string to the console using the WriteLine method.
6. End the SortAndDisplayWords method.
7. End the Main method.
8. End the SortWords class.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images