- GET IN LINE – Write a program that uses an ArrayList to store a list of names for people who are standing in a line. Initially, the list should contain (in the order given): Andrew, Sarah, Will, Evelyn and David. The program should then carry out the following activities:
·
Steven joins the end of the line
·
Evelyn gets out of the line
·
Samantha cuts in line in and gets in position #1 (positions start with 0)
·
Display the current position # for Will*
·
Jessica joins the end of the line
·
Will gets out of the line and rejoins it at the end, behind Jessica
·
Display the name of the person currently in the next to last position in line**
·
The first and last people in line switch places
·
Display a message declaring whether or not a person named David is in the line.***
·
The user enters the name of a new person (use “Chris”) and a position for them to enter the line (use 3). Be sure to error-check the position #, as the line may not contain enough people to make that position possible.
·
All people whose names start with the letter “S” get out of line
·
Display the final order of the people in the line.****
The displayed results should be as follows (use the *’s for reference):
* 3
**Jessica
*** YES or TRUE
**** [Will, Chris, David, Jessica, Andrew].
NOTE: You will likely use every ArrayList method at least once in this program.
|