In: Computer Science
Create an array list (names) that will hold the names of several hall of fame soccer players.
2. Place your name on the screen as the master recorder:
“Master Hall of Fame Recorder: John Paul Jones”
3. Ask the user how many names they would like to record. (input 5 when the program runs)
4. Create a loop that will ask for the “Hall of fame member #1: “, etc Add in the following names:
5. Fill the array list with the names input by the user.
6. Keep track of the grand total of the names in the fill loop.
7. In a separate enhanced (range based) for loop, print the names back out on the screen, following the same format as in step 4.
8. Add in a 6th player named “Hamm”.
9. Using the size function, label and report the number of names recorded.
There are ... hall of fame players recorded.
10. Write the code that will remove the last name “Rooney” from the array list.
11. Label and report the number of names recorded.
There are now … hall of fame players recorded.
12. Clear all elements from the array list.
13. Label and report the number of players recorded.
After clearing all data, there are …hall of fame players recorded
14. Give some clever goodbye message.
Use good spacing in the code and the output. Print the code and a screenshot and turn it in. Submit to Canvas. No screen shot required.
Code
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scnr=new Scanner(System.in);
ArrayList<String>names=new ArrayList<>();
int num_names;
System.out.println("***Master Hall of Fame Recorder: John Paul
Jones***");
System.out.print("\nHow many names they would like to record?
");
num_names=scnr.nextInt();
System.out.println("");
for(int i=0;i<num_names;i++){
System.out.print("Hall of fame member #"+(i+1)+": ");
names.add(scnr.next());
}
System.out.println("\nHall of Fame Records:");
for(int i=0;i<names.size();i++)
System.out.println(names.get(i));
names.add("Hmmm");
System.out.println("\nThere are "+names.size()+" hall of fame
players recorded.");
names.remove("Rooney");
System.out.println("\nThere are "+names.size()+" hall of fame
players recorded.");
names.clear();
System.out.println("\n After clearing all data, there are
"+names.size()+" hall of fame players recorded");
System.out.println("\nThanks for using my App!!\nGood
Byee!!!\n");
}
}
output
If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.