Hi, I have an assignment for object-oriented programming class where I have to make a contact list manager. The program gives you the option of creating business or personal contacts. Then you can print the contacts from the menu. I am having trouble getting it to print out. Here is the requirements for that part of the assignment:
Output Requirements
1. Display the results to the user on screen in a readable and descriptive format (e.g., System.out) by doing the following:
a. Display all contacts’ first and last names when the “display contacts” command is selected.
b. Include a numeric key for each contact that will be used to invoke the method that displays the contact details.
2. Include a prompt that allows the user to enter the numeric key to display all details of the contact in a readable and descriptive format (e.g., System.out, output to a text file using FileWriter).
a. Identify contacts by type when displaying the details of a contact: business or personal.
Here is my code for that part:
When I choose the menu option to display the contacts, all it shows is the number of contacts in records. Can anyone help me fix this? I would greatly appreciate any help!int counter = 0; String line = null; // Location of file to read File file = new File("contactlist.csv"); // Sort contacts and print to console try { try (Scanner scanner = new Scanner(file)) { Set<String> lines = new TreeSet<>(); while (scanner.hasNextLine()) { line = scanner.nextLine(); lines.add(line); counter++; } // Print sorted contacts to console. for (String fileLine : lines) { String outlook = fileLine.substring(0, 1).toUpperCase() + fileLine.substring(1); System.out.println(outlook); } } } catch (FileNotFoundException e) { } System.out.println("\n" + counter + " contacts in records."); }