Hey I'm having trouble with this program, for some reason im stuck and dont know what to do. If you could help me out that woud be great. What i have to do it this.

Using classes, arrays, sorting and searching write a java program to manage an online address book to keep track of the names, addresses, phone numbers and birthdays of family members, close friends, and business associates. Your program should be able to handle a maximum of 20 entries.

The program should perform the following operations:
• Load the data into from a file into an array of address book
• Sort the address book by last name
• Search for a person by last name
• Print the address, phone number, and date of birth of a given person
• Print the names of people whose birthdays are in a given months
• Print the names of all people between two last names.

need to have a 2 classes: main and address book

So you have to load the information of the people from a file?
Do you have a file with peoples information already?

yeah this is the file that we have to use.

Shelly Malik
12 8 2000
Lincoln Drive
Omaha
Nebraska
68131
402-555-1212
Family
Donald Duck
10 6 1980
Disney Street
Orlando
Florida
11234
622-873-8920
Friend
Chelsea Tomek
12 8 1999
Kennedy Blvd
Omaha
Nebraska
68172
402-777-8888
Friend
Goof Goofy
2 6 1965
Disney Street
Los Angles
California
91340
215-782-9000
Family
Brave Balto
2 6 1975
Disney Road
Orlando
Florida
35672
415-782-5555
Business
Bash Bashfull
2 8 1965
Long Road
New York
New York
01101
212-782-8000
Friend

Have you written any code? Look at your requirements:

-Load the data into from a file into an array of address book

So create an AddressBook class. Personaly I don't like the name of the class given by the assignent, because an AddressBook has many entries, but assume fot the exercise that AddressBook is one entry, with data for the person and you will have an array of AdressBooks.

What attributes will the AddressBook have? Write seperate methods that do what is asked in each of the requirements and then have one array of AddressBooks and call them.

Search this forum for examples on how to read files and how to create menus

So for this is what i have for my class, but i don think im doing it right.
package Address;

import java.io.Console;
import java.util.Scanner;
import java.util.Vector;
/**
 * 
 * AddressBook object with variables firstname, lastName, Birthday, City, State,
 * PhoneNumber, ZipCode, Month, Day, Year.
 * 
 */
public class Address {
	String address;
	private String firstName;
	private String lastName;
	private String birthday;
	private String city;
	private String state;
	private String phonenumber;
	private String zipcode;
	private String month;
	private String day;
	private String year;
	
	Address(String firstName, String lastName, String birthday, String city, String state, String phonenumber,
			String zipcode, String month, String day, String year){
		
		this.firstName = "";
		this.lastName = "";
		this.birthday = "";
		this.city = "";
		this.state = "";
		this.phonenumber = "";
		this.zipcode = "";
		this.month = "";
		this. day = "";
		this.year = "";
	}
	/**
	 * 
	 * return the first name
	 */
	public String getfirstName() {
		return this.firstName;
	}

	/**
	 * 
	 * Set first name
	 */
	public void setfirstName(String newfirstName) {
		this.firstName = newfirstName;
	}
	/**
	 * 
	 * return the last name
	 */
	public String getlastName() {
		return this.lastName;
	}

	/**
	 * 
	 * set last name
	 */
	public void setlastName(String newlastName) {
		this.lastName = newlastName;
	}
	/**
	 * 
	 * return the birthday
	 */
	public String getBirthday() {
		return this.birthday;
	}

	/**
	 * 
	 * Set Birthday
	 */
	public void setBirthday(String newBirthday) {
		this.birthday = newBirthday;
	}
	/**
	 * 
	 * return the City
	 */
	public String getCity() {
		return this.city;
	}

	/**
	 * 
	 * Set the city 
	 */
	public void setCity(String newCity) {
		this.city = newCity;
	}
	/**
	 * 
	 * return the state
	 */
	public String getState() {
		return this.state;
	}

	/**
	 * 
	 * set the state
	 */
	public void setState(String newState) {
		this.state = newState;
	}
	/**
	 * 
	 * return the zipcode
	 */
	public String getZipCode() {
		return this.zipcode;
	}

	/**
	 * 
	 * set the zipcode
	 */
	public void setZipCode(String newZipCode) {
		this.zipcode = newZipCode;
	}
	/**
	 * 
	 * return the phone number
	 */
	public String getPhoneNumber() {
		return this.phonenumber;
	}

	/**
	 * 
	 * Set Phone Number
	 */
	public void setPhoneNumber(String newPhoneNumber) {
		this.phonenumber = newPhoneNumber;
	}
	/**
	 * 
	 * return the Month
	 */
	public String getMonth() {
		return this.month;
	}

	/**
	 * 
	 * set the Month
	 */
	public void setMonth(String newMonth) {
		this.month = newMonth;
	}
	/**
	 * 
	 * return the day
	 */
	public String getDay() {
		return this.day;
	}

	/**
	 * 
	 * @param newName An updated name for the song
	 */
	public void setDay(String newDay) {
		this.day = newDay;
	}
	/**
	 * 
	 * return the Year
	 */
	public String getYear(){
		return this.year;
	}

	/**
	 * 
	 * Set the year
	 */
	public void setYear(String newYear) {
		this.year = newYear;
	}
	/**
	 * 
	 * toString all of the objects
	 */
	public String toString() {
		return "fisrtName=" + firstName + " " + "lastName=" + lastName + " " + "birthday=" + birthday + " " + "city="
		+ city + " " + "State=" + state + " " + "zipcode=" + zipcode + " " + "phonenumber=" + phonenumber + 
		" " + "month=" + month + " " + "day=" + day + " " + "year=" + year;
		
	}

{
	
	for( int i = 0; i<number; i++){
	
	System.out.println();
	
	System.out.println("Enter contact "+(i+1)+ " first name:");
	
	firstName[i] = console.next();
	
	outputStream.println();
	
	outputStream.println("First name: "+first[i]);
	
	System.out.println("Enter contact "+(i+1)+ " last name:");
	
	last[i] = console.next();
	
	outputStream.println("Last name: "+last[i]);
	
	System.out.println("Enter contact " +(i+1)+ " home address.");
	
	home[i] = Console.next();
	
	outputStream.println("Home Address: "+home[i]);
	
	System.out.println("Enter contact " +(i+1)+ " home phone");
	
	phone[i] = console.next();
	
	outputStream.println("Home Number: "+phone[i]);
	
	System.out.println("Enter contact "+(i+1)+" Birthday");
	
	cell[i] = Console.next();
	
	outputStream.println("Birthday: "+birthday[i]);
	
	System.out.println();
	}
public static void main(String[] args) {
		
		Scanner console = new Scanner(System.in);
		Vector <String> namelist = new Vector <String>();
		Vector <String> bubble = new Vector <String>();
		Vector <String> select = new Vector <String>();
		
		//sequential search
		System.out.println("Sequential Search");
		getData(namelist);
		System.out.println("Enter a name to search for: ");
		String seqTerm= console.next();
		int result=seqSearch(namelist, seqTerm);
		if (result==-1)
			System.out.println("The name you searched for, "+seqTerm+", was not found.");
		else
			System.out.println("The name you searched for, "+seqTerm+", was found at location " + (result+1)+".");
		
		//bubble sort
		System.out.println("Bubble Sort");
		getData(bubble);
		bubbleSort(bubble);
		System.out.println(bubble);
		
		//selection sort
		System.out.println("Selection Sort");
		getData(select);
		selectionSort(select);
		System.out.println(select);
		
		//binary search
		System.out.println("Binary Search");
		System.out.println("Enter a name to search for: ");
		String bin=console.next();
		int blah=binarySearch(select, bin);
		if(blah==-1)
			System.out.println("Your search item was not found.");
		else
			System.out.println("Your search item was found at location "+(blah+1)+".");
	}
	
	
	
	public static void getData(Vector <String> list)
	{
		Scanner console = new Scanner(System.in);
		String str ="0.0";
		while (!str.equals("-1"))
		{
			System.out.println("Enter a last name, or enter -1 to quit: ");
			str=console.next();
			if (str.compareTo("-1")!=0)
				list.addElement(str);
		}
		
	}
	public static int seqSearch(Vector <String> namelist , String searchItem)
	{
		
		int loc;
		boolean found = false;
		for (loc = 0; loc < namelist.size()-1; loc++)
			if (namelist.elementAt(loc).equals(searchItem))
				{
					found = true;
					break;
				}
		if (found)
			return loc;
		else
			return -1;
	}
	public static void bubbleSort(Vector <String> bubble)
		{
			
			String temp;
			int counter, index;
			for (counter = 0; counter < bubble.size()-1; counter++)  
			{
				
				for (index = 0; index < (bubble.size()-1 - counter); index++)
					if (bubble.elementAt(index).compareTo(bubble.elementAt(index+1))>0) 
					{
						temp = bubble.elementAt(index);
						
						bubble.setElementAt(bubble.elementAt(index + 1),index);
						bubble.setElementAt(temp,index+1);
					}
			}
		} 
	public static void selectionSort(Vector <String> select)
	{

		int index;
		int smallestIndex;
		int minIndex;
		String temp;
		for (index = 0; index < select.size() - 1; index++)
		{
			smallestIndex = index; 
			for (minIndex = index + 1; minIndex < select.size(); minIndex++)
				if (select.elementAt(minIndex).compareTo(select.elementAt(smallestIndex))<0)
					smallestIndex = minIndex; 
			
			temp = select.elementAt(smallestIndex);
			select.setElementAt(select.elementAt(index),smallestIndex);
			select.setElementAt(temp,index);
		}
	}
	public static int binarySearch(Vector <String> binary,String searchItem)
	{
		int first = 0;
		int last = binary.size() - 1;
		int mid=0;
		boolean found = false;
		while (first <= last && !found)
		{
			mid = (first + last) / 2;
			if (binary.elementAt(mid).compareTo(searchItem)==0)
				found = true;
			else
				if (binary.elementAt(mid).compareTo(searchItem) > 0)
					last = mid - 1;
				else
					first = mid + 1;
		}
		if (found) 
			return mid;
		else
			return -1;
	} //end binarySearch

}

	{
	 
This is what i have done for my main class. And know im stuck 

import java.io.*;
import java.util.*;

public class Main
{
    static Scanner console = new Scanner(System.in);

    public static void main(String[] args) throws FileNotFoundException
    {
        AddressBook [] addressBook = new AddressBook[20];

        loadAddressBook(addressBook);
 	sort(addressBook);

        choice=showMenu();
      
        System.out.println("1. Add a person to the address book.");
        System.out.println("2. See if a person is in the address book.");  
        System.out.println("3. Print the address book.");
        System.out.println("4. Save the address book to disk.");
        System.out.println("5. Load the address book from disk.");
        System.out.println("6. Terminate the program.");
      
        int answer = console.nextInt();

        while (choice != quit)
        {
            switch (choice)
            {
            case 1: System.out.print("Enter the last name of the person: ");
                    str = console.nextLine();
                    System.out.println();

                    loc =  search(addressBook,str);

                    if (loc != -1)
                        System.out.println(str + " is in the address book");
                    else
                        System.out.println(str + " is not in the address book");
                    break;
            case 2:  ...etc
               
            case 7:  
            default: System.out.println("Invalid choice.");
            }

            choice=showMenu();
            
        }


        char response;

        System.out.print("Save data Yes (Y/y) No(N/n)?: ");
        response = console.nextLine().charAt(0);
        System.out.println();

        if (response == 'y' || response == 'Y')
            saveData(addressBook);
    }

    public static void loadAddressBook(AddressBook adBook) throws
                                                            FileNotFoundException
    {
        Scanner inFile = new Scanner(new FileReader("a:\\Ch11_Ex6Data.txt"));

        int i = 0;

        while (inFile.hasNext())
        {
            first = inFile.next();
            last = inFile.next();

            month = inFile.nextInt();
            day = inFile.nextInt();
            year = inFile.nextInt();
            inFile.nextLine();
            street = inFile.nextLine();
            city = inFile.nextLine();
            state = inFile.nextLine();
            zip = inFile.nextLine();
            phone = inFile.nextLine();
            pStatus = inFile.nextLine();

            temp = new Addressbook();
            temp.setInfo(first, last, month, day, year, street, zip, phone, pSatus);

            adBook[i].insert(temp);
            i++;
        }
    }

    

public static void saveData(AddressBook list) throws
                                                    FileNotFoundException
    {
        PrintWriter outfile;

        String filename;

        System.out.println("Enter file name: ");
        filename = console.nextLine();
        System.out.println();

        outfile = new PrintWriter(filename);
 
		String first;
		String last;

		 

		for (int i = 0; i < length; i++)
		{
			first = list[i].getFirstName();
			last = list[i].getLastName();
			 

			outFile.println(first + " " + last);
			 
		}
	}
    }

    public static int showMenu()
    {
         
    }
}

Edited 6 Years Ago by Nick Evan: added code tags

try wrapping your code in code tags so it easier for us to read.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

package Address;

import java.io.Console;
import java.util.Scanner;
import java.util.Vector;
/**
 * 
 * AddressBook object with variables firstname, lastName, Birthday, City, State,
 * PhoneNumber, ZipCode, Month, Day, Year.
 * 
 */
public class Address {
    String address;
    private String firstName;
    private String lastName;
    private String birthday;
    private String city;
    private String state;
    private String phonenumber;
    private String zipcode;
    private String month;
    private String day;
    private String year;

    Address(String firstName, String lastName, String birthday, String city, String state, String phonenumber,
            String zipcode, String month, String day, String year){

        this.firstName = "";
        this.lastName = "";
        this.birthday = "";
        this.city = "";
        this.state = "";
        this.phonenumber = "";
        this.zipcode = "";
        this.month = "";
        this. day = "";
        this.year = "";
    }
    /**
     * 
     * return the first name
     */
    public String getfirstName() {
        return this.firstName;
    }

    /**
     * 
     * Set first name
     */
    public void setfirstName(String newfirstName) {
        this.firstName = newfirstName;
    }
    /**
     * 
     * return the last name
     */
    public String getlastName() {
        return this.lastName;
    }

    /**
     * 
     * set last name
     */
    public void setlastName(String newlastName) {
        this.lastName = newlastName;
    }
    /**
     * 
     * return the birthday
     */
    public String getBirthday() {
        return this.birthday;
    }

    /**
     * 
     * Set Birthday
     */
    public void setBirthday(String newBirthday) {
        this.birthday = newBirthday;
    }
    /**
     * 
     * return the City
     */
    public String getCity() {
        return this.city;
    }

    /**
     * 
     * Set the city 
     */
    public void setCity(String newCity) {
        this.city = newCity;
    }
    /**
     * 
     * return the state
     */
    public String getState() {
        return this.state;
    }

    /**
     * 
     * set the state
     */
    public void setState(String newState) {
        this.state = newState;
    }
    /**
     * 
     * return the zipcode
     */
    public String getZipCode() {
        return this.zipcode;
    }

    /**
     * 
     * set the zipcode
     */
    public void setZipCode(String newZipCode) {
        this.zipcode = newZipCode;
    }
    /**
     * 
     * return the phone number
     */
    public String getPhoneNumber() {
        return this.phonenumber;
    }

    /**
     * 
     * Set Phone Number
     */
    public void setPhoneNumber(String newPhoneNumber) {
        this.phonenumber = newPhoneNumber;
    }
    /**
     * 
     * return the Month
     */
    public String getMonth() {
        return this.month;
    }

    /**
     * 
     * set the Month
     */
    public void setMonth(String newMonth) {
        this.month = newMonth;
    }
    /**
     * 
     * return the day
     */
    public String getDay() {
        return this.day;
    }

    /**
     * 
     * @param newName An updated name for the song
     */
    public void setDay(String newDay) {
        this.day = newDay;
    }
    /**
     * 
     * return the Year
     */
    public String getYear(){
        return this.year;
    }

    /**
     * 
     * Set the year
     */
    public void setYear(String newYear) {
        this.year = newYear;
    }
    /**
     * 
     * toString all of the objects
     */
    public String toString() {
        return "fisrtName=" + firstName + " " + "lastName=" + lastName + " " + "birthday=" + birthday + " " + "city="
        + city + " " + "State=" + state + " " + "zipcode=" + zipcode + " " + "phonenumber=" + phonenumber + 
        " " + "month=" + month + " " + "day=" + day + " " + "year=" + year;

    }

{

    for( int i = 0; i<number; i++){

    System.out.println();

    System.out.println("Enter contact "+(i+1)+ " first name:");

    firstName[i] = console.next();

    outputStream.println();

    outputStream.println("First name: "+first[i]);

    System.out.println("Enter contact "+(i+1)+ " last name:");

    last[i] = console.next();

    outputStream.println("Last name: "+last[i]);

    System.out.println("Enter contact " +(i+1)+ " home address.");

    home[i] = Console.next();

    outputStream.println("Home Address: "+home[i]);

    System.out.println("Enter contact " +(i+1)+ " home phone");

    phone[i] = console.next();

    outputStream.println("Home Number: "+phone[i]);

    System.out.println("Enter contact "+(i+1)+" Birthday");

    cell[i] = Console.next();

    outputStream.println("Birthday: "+birthday[i]);

    System.out.println();
    }
public static void main(String[] args) {

        Scanner console = new Scanner(System.in);
        Vector <String> namelist = new Vector <String>();
        Vector <String> bubble = new Vector <String>();
        Vector <String> select = new Vector <String>();

        //sequential search
        System.out.println("Sequential Search");
        getData(namelist);
        System.out.println("Enter a name to search for: ");
        String seqTerm= console.next();
        int result=seqSearch(namelist, seqTerm);
        if (result==-1)
            System.out.println("The name you searched for, "+seqTerm+", was not found.");
        else
            System.out.println("The name you searched for, "+seqTerm+", was found at location " + (result+1)+".");

        //bubble sort
        System.out.println("Bubble Sort");
        getData(bubble);
        bubbleSort(bubble);
        System.out.println(bubble);

        //selection sort
        System.out.println("Selection Sort");
        getData(select);
        selectionSort(select);
        System.out.println(select);

        //binary search
        System.out.println("Binary Search");
        System.out.println("Enter a name to search for: ");
        String bin=console.next();
        int blah=binarySearch(select, bin);
        if(blah==-1)
            System.out.println("Your search item was not found.");
        else
            System.out.println("Your search item was found at location "+(blah+1)+".");
    }



    public static void getData(Vector <String> list)
    {
        Scanner console = new Scanner(System.in);
        String str ="0.0";
        while (!str.equals("-1"))
        {
            System.out.println("Enter a last name, or enter -1 to quit: ");
            str=console.next();
            if (str.compareTo("-1")!=0)
                list.addElement(str);
        }

    }
    public static int seqSearch(Vector <String> namelist , String searchItem)
    {

        int loc;
        boolean found = false;
        for (loc = 0; loc < namelist.size()-1; loc++)
            if (namelist.elementAt(loc).equals(searchItem))
                {
                    found = true;
                    break;
                }
        if (found)
            return loc;
        else
            return -1;
    }
    public static void bubbleSort(Vector <String> bubble)
        {

            String temp;
            int counter, index;
            for (counter = 0; counter < bubble.size()-1; counter++)  
            {

                for (index = 0; index < (bubble.size()-1 - counter); index++)
                    if (bubble.elementAt(index).compareTo(bubble.elementAt(index+1))>0) 
                    {
                        temp = bubble.elementAt(index);

                        bubble.setElementAt(bubble.elementAt(index + 1),index);
                        bubble.setElementAt(temp,index+1);
                    }
            }
        } 
    public static void selectionSort(Vector <String> select)
    {

        int index;
        int smallestIndex;
        int minIndex;
        String temp;
        for (index = 0; index < select.size() - 1; index++)
        {
            smallestIndex = index; 
            for (minIndex = index + 1; minIndex < select.size(); minIndex++)
                if (select.elementAt(minIndex).compareTo(select.elementAt(smallestIndex))<0)
                    smallestIndex = minIndex; 

            temp = select.elementAt(smallestIndex);
            select.setElementAt(select.elementAt(index),smallestIndex);
            select.setElementAt(temp,index);
        }
    }
    public static int binarySearch(Vector <String> binary,String searchItem)
    {
        int first = 0;
        int last = binary.size() - 1;
        int mid=0;
        boolean found = false;
        while (first <= last && !found)
        {
            mid = (first + last) / 2;
            if (binary.elementAt(mid).compareTo(searchItem)==0)
                found = true;
            else
                if (binary.elementAt(mid).compareTo(searchItem) > 0)
                    last = mid - 1;
                else
                    first = mid + 1;
        }
        if (found) 
            return mid;
        else
            return -1;
    } //end binarySearch

}

    {

Edited 3 Years Ago by mike_2000_17: Fixed formatting

You have a constructor that has lots of arguments, but you don't pass them to your local variables: this.firstName = firstName; Remove the for loop that you have hanging in the class. It doesn't do anything.
You also don't need anything in the Address class so remove the main method.

In another class, have the main method. Create an array of Addresses or better a Vector of Addresses. Since you already have the Address class why use an array of firstnames?

Vector<Address> addS = new Vector<Address>();

Address ad1 = new Address(.....);
Address ad2 = new Address(.....);
....

addS.add(ad1);
addS.add(ad2);

In the main method put the code that loads and uses the Vector. Search this forum for examples on how to create a menu.

This article has been dead for over six months. Start a new discussion instead.