Question: Java DO NOT USE ARRAYLISTS. THIS PROGRAM IS ASSESSING YOUR ABILITY TO MANIPULATE ARRAYS. You will create a program which implements file I/O, as well
Java
DO NOT USE ARRAYLISTS. THIS PROGRAM IS ASSESSING YOUR ABILITY TO MANIPULATE ARRAYS.
You will create a program which implements file I/O, as well as several methods which perform specific array functions.
Input: A database formatted as shown below. The first line of the file will indicate how many entries there are in the file. Please code your program to accept input.txt as the input file.
Sample input:
7
Twist J
Orlando A
Peechatt T
Cicchetti F
Notten L
Guerrero J
Andrighetti E
Your program will store these names in a sorted array.
Offer the user a menu with the following options:
1. Add
2. Delete
3. Display
4. Write to File
5. Exit
Add: This menu option prompts the user to enter a last name and first initial to add to the array. The array should be in alphabetical order after the name has been added.
Delete: This menu option prompts the user to enter a last name to search for in the array. If the last name is not in the array, print the message Name not found. If the last name is in the array, confirm the first initial with the user. If the first initial matches, delete the name from the array. The array should be in alphabetical order after the name has been subtracted.
Display: Print the array.
Write to File: Prompt the user for a filename. Write the contents of the array to the file, using the same format as the input file. OPTIONAL EXTRA CHALLENGE: Keep track of the file names the user has entered and refuse to write to a file if the filename entered has already been used.
Exit: Write the contents of the array to a file labeled output.txt using the same format as the input file, and exit the program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
