• 100% Satisfaction Guarantee
R.R. Jha, Tutor
Category: Homework
Satisfied Customers: 5471
Experience:  B.Tech
20870358
R.R. Jha is online now

# I am doing a program to alpabetize a list of last names. The

I am doing a program to alpabetize 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.
The 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

Tips

Best practices: Don't try to write too much at a time! First, write an outline in comments based on the requirements and the pseudocode. Then, work on instantiating an ArrayList object, followed by implementing the loop that will get user input. As always, keep things simple and implement incrementally. Review the list of ArrayList methods and properties in the textbook and experiment with the ones you think you'll need.

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
Customer: replied 3 years ago.

namespace

LAB5B

{

classProgram

{

staticvoid Main(string[] args)

{

List<string> names = newList<string>();

do

{

string lastName;

Console.Write("Enter a last name: ");

lastName =

Console.Write("Keep going? (Y/N): ");

}

Console.WriteLine("\n{counter} names entered");

names.Sort();

foreach (var name in names)

{

Console.WriteLine(name);

}

Console.WriteLine("\nNames in Descending Order\n");

names.Reverse();

foreach (var name in names)

{

Console.WriteLine(name);

}

}

}

how soon you need this
Customer: replied 3 years ago.

i would like it by tonight no later then 11pm

ok will you be able to review my answer and rate as soon as i give answer?
Customer: replied 3 years ago.

are you finish

i havent even started as you didnt answer my last question will you be able to review my answer and rate as soon as i give answer? As i see you didnt rate the answer given by previous expert even though he gave you the answer

Customer: replied 3 years ago.

yes. i will do it right after

Customer: replied 3 years ago.