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

Needed in C# please Your mission: Write a program to alphabetize a list of last

ID: 3684785 • Letter: N

Question

Needed in C# please

Your mission: Write a program to alphabetize a list of last names. The user will input an undetermined number of last names. The program will display the number of names entered and alphabetized lists of the names in ascending (A-Z) and descending (Z-A) order.

Your program will store the names in an ArrayList object. It will use various ArrayList properties and methods to implement the program requirements.

Sample output:

Enter a last name: Roberts
Keep going? (Y/N): y
Enter a last name: DeLay
Keep going? (Y/N): y
Enter a last name: Foreman
Keep going? (Y/N): y
Enter a last name: Ganguly
Keep going? (Y/N): n

4 last names entered

Names in Ascending Order

DeLay
Foreman
Ganguly

Names in Descending Order

Roberts
Ganguly
Foreman
DeLay

Please follow the pseudocode as closely as possible:

Pseudocode

Main function

Instantiate ArrayList object

Loop to get last names, until user wants to quit

Add each last name to the ArrayList

Display the count of the last names

Sort the ArrayList

Loop to display the names

Reverse the order of the ArrayList

Loop to display the names

Again, program needed in C# thank you.

Explanation / Answer

sample code logic to sort array of strings in c#

using System;

using System.Linq;

class Program

{

    static void Main()

    {

string []answer = new string[10];

for(int i = 0;i<answer.length;i++)

{

Console.WriteLine("Enter the string");

            answer[i]= Console.ReadLine();

}

Array.Sort(answer);

            foreach (string s in answer)

            {

Console.WriteLine("Ascending order");

                Console.WriteLine(s);

            }

var desc = from s in answer

                           orderby s descending

                           select s;

foreach (string c in desc)

            {

Console.WriteLine("Descending order");

                Console.WriteLine(c);

            }

    }

}

note-the above code can help to answer the given question.

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