Input a list of names from the user and display only those names which are starting with ‘A’.
Answers
Answer:
1. Write a program to input a list of names (strings) from the user and store them
in an ArrayList. The input can be terminated by entering the empty string or
by
entering the string “quit”.
2. Add further functionality to your program so that it searches the ArrayList to
find the first string and the last string according to dictionary ordering and
then prints out these strings (names). Do this exercise without sorting the
names in the ArrayList. For example, if the list contains the following names:
Charles Darwin
Albert Einstein
Issac Newton
Tony Hoare
Grace Hopper
Edgar Dijkstra
Ada Lovelace
Charles Babbage
Stephen Hawking
Your program should output:
The first name in the list in alphabetical order is: Ada Lovelace
The last name in the list in alphabetical order is: Tony Hoare
3. Add to your program so that after completing question 2, it sorts the ArrayList
to put all strings (names) in (alphabetical) order and prints them all out in
order.
Explanation: