QuestionQuestion

Transcribed TextTranscribed Text

Questions 1- Write a command line application to store and retrieve names and addresses. Each entry should consist of the following data: Field Constraints Examples Name Only letters allowed, Sara. Jack William at least one character House Number At least one digit 24,13,16b followed by at most one letter Street Name Only letters allowed, Gcorge, Marling street at least one character Town Only letters allowed, Liverpool, London at least one character Postcode 2 upper case letters, CF112NN 3 digits, 2 upper case letters a) The application should have the ability to: load and save the address book to file (in binary or text format); create a new (empty) address book; add entries; display the entire address book to screen; display all entries whose name field contains a specified substring. (b) Add the extra functionality: delete entries (specified by their position in the list); find all addresses that contain a given substring in any of the data fields; display a specified subset of the address book to screen (for example, entries 5 to 8).

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Scanner;







public class AddressBook {



private static ArrayList<Contact> contacts=null;



public AddressBook(Contact c){

this.contacts = new ArrayList<Contact>();

this.contacts.add(c);

}

public AddressBook(){

this.contacts= new ArrayList<Contact>();

}



public void addContact(){

Scanner sc= new Scanner(System.in);

System.out.println("Do you want to make an empy address book? y/n");

if(sc.nextLine().equals("y")){

AddressBook a= new AddressBook();

}

else{

System.out.println("Enter a name and last name");

String name=sc.nextLine();

System.out.println("Enter a house number");

String number= sc.nextLine();

System.out.println("Enter a name of the street");

String street=sc.nextLine();



System.out.println("Enter a name town ");

String town= sc.nextLine();

System.out.println("Enter a postcode");

String postcode= sc.nextLine();

Contact c= new Contact(name, number, street, town, postcode);

this.contacts.add(c);

sc.close();

}

}

@Override...

By purchasing this solution you'll be able to access the following files:
solution.docx.

$60.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats