Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The file must be called <LastFirstChapter10.java> (driver program) LiFiAddressBo

ID: 3545388 • Letter: T

Question

                    The file must be called <LastFirstChapter10.java> (driver program) LiFiAddressBook.java
                    Ensure you include ALL files required to make your program compile and run. I would like to see your .java files only.
                    If possible, submit all programs as a single .zip file (not required)
                    Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital                     letter.                 

                

                    
                    Overall Requirements
                    Write a program that simulates an address book.                 

                

                    
                    Driver main method should be as shown below. Add comments to explain functionality:                 

                

                    
                

                

                    import java.util.ArrayList;
                    public class LastFirstChapter10
                    //Replace LastFirst with your Last Name and First Name
                    {
                    public static void main(String [] args)
                    {
                    ArrayList<LiFiAddressBook> aBook = new ArrayList<LiFiAddressBook>();
                    //Replace LiFi with Last Initial First Initial (for all instances)
                    for (int count = 0; count < 1; count++) //change 1 to add more than 1
                    {
                    //****************************
                    //add code here to add new entry to ArrayList
                    //call addEntry
                    //print blank line
                    //****************************
                    }
                    int foundIndex = LiFiAddressBook.search(aBook);
                    System.out.println();
                    if (foundIndex > -1)
                    aBook.get(foundIndex).display();
                    else
                    System.out.println("No Entry Found");
                    }
                    }
                

                

                    
                

                

                    
                

                

                    
                    Output should be as shown in example at bottom.                 

                

                    
                    LiFiAddressBook.java class
                    Instance variables:
                    First Name (string) Last Name (string) Street Address (string) City State (string) Zip Code (string)
                    addEntry method:
                    Get input for variables above. See sample in example at bottom.
                    search method:
                    Receive ArrayList as argument
                    Output Search Menu (see example at bottom)
                    Utilize a switch and search ArrayList for field specified.
                    Return index number if entry found or -1 if not found
                    display method:
                    Print results as shown in example at bottom.
                    
                    Sample session :
                    Please Enter First Name: Ken
                

                

                    PleaseEnter Last Name: Dewey
                

                

                    Please Enter Street Address: 6420 SE 15th St.
                

                

                    Please Enter City, State: Midwest City, OK
                

                

                    Please Enter Zip Code: 73110
                    Please Enter First Name: Nick
                

                

                    Please Enter Last Name: Dewey                 

                

                    Please Enter Street Address: 3232 Longridge Rd.
                

                

                    Please Enter City, State: Del City, OK
                

                

                    lease Enter Zip Code: 73115
                    Please Enter First Name: Steve
                

                

                    Please Enter Last Name: Jones                 

                

                    Please Enter Street Address: 1205 Waynes Place
                

                

                    Please Enter City, State: Moore, OK
                

                

                    Please Enter Zip Code: 73024                 

                

                    
                    Search Menu;
                

                

                    1. First Name
                

                

                    2. Last Name
                

                

                    3. Street Address
                

                

                    4. City, State
                

                

                    5. Zip Code                 

                

                    
                    Please Enter Field to Search: 1
                    Please enter value to search for: Nick
                    First Name: Nick
                

                

                    Last Name: Dewey
                

                

                    Street Address: 3232 Longridge Rd.
                

                

                    City, State: Del City, OK
                

                

                    Zip Code: 73115                 

                                     
                    If the item is not found:
                    No Entry Found

Explanation / Answer

________________________________________________________________________________________________


*********************************************   LastFirstChapter10 .java ****************************************************

________________________________________________________________________________________________

import java.io.IOException;

import java.util.ArrayList;

public class LastFirstChapter10

// Replace LastFirst with your Last Name and First Name

{

public static void main(String[] args) throws NumberFormatException, IOException

{

ArrayList<LiFiAddressBook> aBook = new ArrayList<LiFiAddressBook>();

// Replace LiFi with Last Initial First Initial (for all instances)

for (int count = 0; count < 1; count++) // change 1 to add more than 1

{

LiFiAddressBook newEntry=new LiFiAddressBook();

aBook.add(newEntry);//Adding new entry into the array list

LiFiAddressBook.addEntry(newEntry);

System.out.println();

}

int foundIndex = LiFiAddressBook.search(aBook);

System.out.println();

if (foundIndex > -1)

aBook.get(foundIndex).display();

else

System.out.println("No Entry Found");

}

}




________________________________________________________________________________________________


********************************************* LiFiAddressBook .java *******************************************************

________________________________________________________________________________________________



import java.io.*;

import java.util.ArrayList;


public class LiFiAddressBook

{

String FirstName;

String LastName;

String StreetAddress;

String CityState;

String ZipCode;

public static void addEntry(LiFiAddressBook entry) throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

//Get the first name as a input and store it in the entry object

System.out.print("Please Enter First Name: ");

entry.FirstName=br.readLine();

//Get the last name as a input and store it in the entry object

System.out.print("Please Enter Last Name: ");

entry.LastName=br.readLine();

//Get the address as a input and store it in the entry object

System.out.print("Please Enter Street Address:");

entry.StreetAddress=br.readLine();

//Get the city,state as a input and store it in the entry object

System.out.print("Please Enter City, State: ");

entry.CityState=br.readLine();

//Get the zip code as a input and store it in the entry object

System.out.print("Please Enter Zip Code: ");

entry.ZipCode=br.readLine();

}




public static int search(ArrayList<LiFiAddressBook> aBook) throws NumberFormatException, IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("1. First Name");

System.out.println("2. Last Name");

System.out.println("3. Street Address");

System.out.println("4. City, State");

System.out.println("5. Zip Code");

System.out.print(" Please Enter Field to Search: ");

int choice=Integer.parseInt(br.readLine());

System.out.print(" Please enter value to search for: ");

String value=br.readLine();

//The array list is iterated through to search if the given value matches the field of any of the entries in the list

for(LiFiAddressBook e:aBook)

{

switch(choice){

case 1:

if(value.equalsIgnoreCase(e.FirstName))

return aBook.indexOf(e);

break;

case 2:

if(value.equalsIgnoreCase(e.LastName))

return aBook.indexOf(e);

break;

case 3:

if(value.equalsIgnoreCase(e.StreetAddress))

return aBook.indexOf(e);

break;

case 4:

if(value.equalsIgnoreCase(e.CityState))

return aBook.indexOf(e);

break;

case 5:

if(value.equalsIgnoreCase(e.ZipCode))

return aBook.indexOf(e);

break;

}

}

return -1;

}




public void display()

{

System.out.println("First Name: "+this.FirstName);

System.out.println("Last Name: "+this.LastName);

System.out.println("Street Address: "+this.StreetAddress);

System.out.println("City, State: "+this.CityState);

System.out.println("Zip Code: "+this.ZipCode);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote