hello smile.gif
i am having trouble with the 2D array i am making.......it is supposed to be an address book of sorts

Miller, Joseph, 910 Auburn Avenue, McLean, VA, 7035551234
Frank, Michael, 1 York Road, Baltimore, MD, 4105551234
Roland, Frank, 346 Bellona Avenue, Lutherville, MD, 4435551234
Smith, Jan, 432 Burke Avenue, Towson, MD, 4105559876
Laurel, Mary, 435 Saint Francis Avenue, Bowie, MD, 4435554567

so basically the 2D array is [5][6] i think unless im counting wrong or including things wrong

this is the information i wish to input into my array.........not real names n stuff of course lol
and this is an example of how i want to run my program or wut it is supposed to be like

System: What do you wish to replace? 1) Last Name, 2) First Name, …

  • User: 1

  • System: Look up the user by… 1) Last Name, 2) First Name, …
  • User: 2

  • System: Enter user’s first name

  • User: Michael

  • System: Enter user’s new last name

  • User: Rogers

  • System: Information for user Michael changed to: [output Michael’s record]

  • System: ***** Address book **************************

  • System: [Full output of the entire list after the change, formatted]
  • this is what i have been working on so far of course it is not complete

  • i got hung up on how to put all the information in......and also i think the way i am going to run the program looks really messy so far but i was trying to use functions for the questions to make it easier for me to read

  • all i need to import and want to import is the javax.swing.*; that i always import
  • p.s. i know this is prolly horribly wrong
import javax.swing.*;

public class xm1
  public static void main(String[] args)
    String[][] addressBook = new String[5][6];
    String[][] names = {{"Miller ", "Frank ", "Roland ", "Smith", "Laurel"},
                        {"Joseph", "Michael", "Frank", "Jan", "Mary"},
                        {"910 Auburn Avenue", "1 York Road", "346 Bellona Avenue", "432 Burke Avenue", "435 Saint Francis Avenue"},
                        {"McLean", "Baltimore", "Lutherville", "Towson", "Bowie"},
                        {"VA", "MD", "MD", "MD", "MD"},
                        {"7035551234", "4105551234", "4435551234", "4105559876", "4435554567"}}

    public static void questionOne()
      Int firstQuestion = JOptionPane.showInputDialog("What do you wish to replace?\n1) First Name\n2) Last Name\n3) Address\n4 Zip Code");
      If(firstQuestion == 1)
        System.out.println("Replace First Name");
        Int secondQuestion = JOptionPane.showInputDialog("Look up user by:\n1) First Name\n2) Last Name\n3) Address\n4 Zip Code");
        If(secondQuestion == 1)
          String firstName = JOptionPane.showInputDialog("Enter User's First Name");
9 Years
Discussion Span
Last Post by JamesCherrill

Are you required to use a 2D array? If not, the Java way to do this is to create a class Address, with fields for first name, second name, address. Then you just have a simple 1D array of Address objects. Even better, if you have the choice, would be an ArrayList of Addresses.


yup i am required to use a 2D array
no scanners......buffer reader........it's ridiculous i know
so much frustration in this

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.