I'm suppose to do this using sorting algorithm..so it asks to creat a friends database application that maintains a file of friend objects that contain names, telephone numberrs, and email adresses..etc. The friends application should load friend records from a file and then allow the user to add new friends, delete friends, display a list of all friends by either first naem or last name, and search for a friend. When The program runs it displays the menu, where add a friend(prompts the user to enter a name) and then delete, search(removes a friend off the list) and stuff...
The program is not done yet.... and I think I should seperate this into two files. can someone help me correct this, like the methods and constructors so that at least it compiles. ...
import java.util.Scanner;
import java.util.Math;
import java.util.ArrayList;
public class FriendsMain {
public static void main(String[] args) {
String friend;
String lastName;
String firstName;
String telephone;
String email;
Scanner input = new Scanner(System.in);
ArrayList = new ArrayList();
do {
System.out.println("\n1. Add a friend. ");
System.out.println("2. Display friends by last name. ");
System.out.println("3. Display friends by first name. ");
System.out.println("4. Find a friend");
System.out.println("5. Delete a friend");
System.out.println("6. Quit");
choice = input.nextInt();
if (choice == 1) {
System.out.println("Enter a friend by their first name");
firstName = input.nextLine();
friendList.add(firstName);
System.out.println("Enter a friend by their last name: ");
lastName = input.nextLine();
friendList.add(lastName);
System.out.println("Enter their telephone number: ");
telephone = input.nextLine();
telephoneList.add(telephone);
System.out.println("Enter their email address: ");
email = input.nextLine();
emailList.add(email);
} else if ( choice == 2) {
friendList.remove(lastName);
} else if (choice == 3) {
displayArray(friendList);
} else if ( choice == 4) {
System.out.println(" Enter a friend to search for: ");
searchName = input.nextInt();
} else if ( choice == 5) {
friendList.remove(friend);
} while (!= 6)
}
}
}
thank you!