Go Back Forums > General > Programming/Html
Programming/Html C++,Visual Basic,HTML,Flash,OpenGL,Modelling,Java.

Thread Tools Display Modes
Address book using JAVA
Master Guru
^Son_Gokou08's Avatar
Videocard: Radeon HD 4850 @780/1200
Processor: Core 2 Duo E7300 @ 4Ghz
Mainboard: Abit IP35P
Memory: TEAM X3M 2*1GB DDR2-800
Soundcard: Onboard Realtek ALC883
PSU: HEC WinPower 550AB
Default Address book using JAVA - 09-24-2008, 17:35 | posts: 171

my friend is having a hard time coding an address book using JAVA PL. i want to help her but unfortunately, i dont know anything about that language. so i told her to give the code to me and i'll try to ask around.

ok, so her problem is with #2 (delete entry).

Create a class AddressBook that can contain 100 entries of AddressBookEntry objects (use the class you created in the first exercise). You should provide the following methods for the address book.

1. Add entry

2. Delete entry

3. View all entries

import javax.swing.*;

public class AddressBook {
public AddressBook() {

public static void main(String[] args) {

int addEntry = 0;
int deleteEntry = 0;
int viewEntry = 0;
int exit = 0;

final int MAX_SIZE = 3;
int[] arrOptions = new int[MAX_SIZE];

int userInput = 0;
int flag = 0;

userInput = Integer.parseInt(JOptionPane.showInputDialog("Ente r what you would like to do: \n[0] ==> Add Entry \n[1] ==> Delete Entry \n[2] ==> View all entry \n[3] ==> Exit"));

for (int i = 0; i < arrOptions.length; i++) {
if (userInput == i){

if (userInput == 0){

String temp = " ";

AddressBookEntry name = new AddressBookEntry();
AddressBookEntry address = new AddressBookEntry();
AddressBookEntry telNum = new AddressBookEntry();
AddressBookEntry eAdd = new AddressBookEntry();

int x = 0;


if (x<=3){
name.setName(JOptionPane.showInputDialog("Enter a Name"));
address.setAddress(JOptionPane.showInputDialog("En ter Address"));
telNum.setTelNum(Integer.parseInt( InputDialog("Enter Tel. Number")));
eAdd.setEAdd(JOptionPane.showInputDialog("Enter E-mail Address"));

temp = temp + "\nEntry number "+x+
"\nTelephone Number:\t"+telNum.getTelNum()+
"\nE-mail Address:\t\t"+eAdd.getEAdd()+"\n";


flag = JOptionPane.showConfirmDialog(null, "Would you like to continue?");
}while (flag==0);
if(flag == 1){
userInput = Integer.parseInt(JOptionPane.showInputDialog("Ente r what you would like to do: \n[0] ==> Add Entry \n[1] ==> Delete Entry \n[2] ==> View all entry \n[3] ==> Exit"));


}catch(Exception e) {
JOptionPane.showMessageDialog(null, "Error!!!");
JOptionPane.showMessageDialog(null, temp);

if (userInput == 1){
JOptionPane.showMessageDialog(null, "Please delete add an entry");
if (userInput == 2){

if (userInput == 3){

} while (flag == 0);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error!");

Last edited by ^Son_Gokou08; 09-24-2008 at 20:29.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
vBulletin Skin developed by:
Copyright (c) 1995-2014, All Rights Reserved. The Guru of 3D, the Hardware Guru, and 3D Guru are trademarks owned by Hilbert Hagedoorn.