How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask R.R. Jha Your Own Question
R.R. Jha
R.R. Jha, Tutor
Category: Homework
Satisfied Customers: 5471
Experience:  B.Tech
20870358
Type Your Homework Question Here...
R.R. Jha is online now
A new question is answered every 9 seconds

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

This answer was rated:

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
Hello Welcome. Thank you for your question, I’m ATLProg and I’ll try to help you.
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.ReadLine();


names.Add(lastName);



 


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


useAnswer =


 


Convert.ToChar(Console.ReadLine());


}


 


while ((useAnswer == 'Y') || (useAnswer == 'y'));



 


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.

I have answer your question. So did you start

THIS ANSWER IS LOCKED!

You need to spend $3 to view this post. Add Funds to your account and buy credits.
R.R. Jha, Tutor
Category: Homework
Satisfied Customers: 5471
Experience: B.Tech
R.R. Jha and 2 other Homework Specialists are ready to help you

Related Homework Questions