2D Array in an Address Book

Using a 2-dimensional array you will store the following information:

Page 1 of 1

3 Replies - 2302 Views - Last Post: 21 October 2009 - 07:41 PM Rate Topic: -----

#1 cece7705  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 21-October 09

2D Array in an Address Book

Post icon  Posted 21 October 2009 - 07:10 PM

Using a 2-dimensional array you will store the following information:
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
Ask the user what information they wish to change given some input.
Example
System: What do you wish to replace? 1) Last Name, 2) First Name, … [list all options]
User: 1
System: Look up the user by… 1) Last Name, 2) First Name, … [list all options]
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]



here is my code so far


import javax.swing.JOptionPane;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.File;
import java.io.*;
import java.util.*;
import java.util.StringTokenizer;

public class Lab7
{

/* String tokenizer, make sure you seperate the data by commas*/
public static void main(String[]args)

throws FileNotFoundException{
System.out.println("Courtney Gibson");
Scanner input = new Scanner(new File("H:\\cgibso1\\addressBook1.csv"));

String [][] phoneBook = new String [50][8];

String userinput =JOptionPane.showInputDialog("Look up the user by\n1)First name\n2)Last name\n3)email adress \n4)Birthdate\n5)Birth year\n6)Birthmonth");
if (userinput.equals ("1"))
{

String targetfirstname = JOptionPane.showInputDialog("Enter firstname\n");

StringTokenizer st= new StringTokenizer("\n");
for(int y = 0; y < phoneBook.length;y++)
while (input.hasNextLine()){
phoneBook[0][y] = input.nextLine();
String firstname = input.nextLine();
if(phoneBook[0][y].equals(targetfirstname))
{
phoneBook[0][y] = targetfirstname;
break;
}
System.out.print(firstname);
}

}
if (userinput.equals ("2"))
userinput =JOptionPane.showInputDialog("Look up the user by\n1)First name\n2)Last name\n3)email adress \n4)Birthdate\n5)Birth year\n6)Birthmonth");
{
String targetlastname= JOptionPane.showInputDialog("Enter last name");
StringTokenizer st = new StringTokenizer("\nUniversity");
for(int y=0;y<phoneBook.length; y++)
while(input.hasNextLine()){
phoneBook[0][y]=input.nextLine();
String lastname = input.nextLine();
if(phoneBook[0][y].equals(targetlastname))
{
phoneBook[0][y] = targetlastname;
break;
}
System.out.print(lastname);
}
}

if(userinput.equals ("3"))
userinput =JOptionPane.showInputDialog("Look up the user by\n1)First name\n2)Last name\n3)email adress \n4)Birthdate\n5)Birth year\n6)Birthmonth");
{


}
if(userinput.equals ("4"))
userinput =JOptionPane.showInputDialog("Look up the user by\n1)First name\n2)Last name\n3)email adress \n4)Birthdate\n5)Birth year\n6)Birthmonth");
{

}
if(userinput.equals ("5"))
userinput =JOptionPane.showInputDialog("Look up the user by\n1)First name\n2)Last name\n3)email adress \n4)Birthdate\n5)Birth year\n6)Birthmonth");
{

}

}
}




/* String text = input.nextLine();
System.out.println(text.toUpperCase());
System.out.print("Courtney Gibson");
*/

/* public static void Lastname()
{

String userinput = JOptionPane.showInputDialog("Look up the user by\n1)First name\n2)Last name\n3)email adress \n4)Birthdate\n5)Birth year\n6)Birthmonth");
if (userinput.equals ("1"))
{
String firstname = JOptionPane.showInputDialog("Enter firstname");
for(int y = 0; y < phoneBook.length;y++)
{
if(phoneBook[0][y].equals(addressBook.csv))
{
phoneBook[0][y] = firstname;

}

/* String targetlastname = JOptionPane.showInputDialog("Enter users First name");

break;
{
if (userinput.equals ("2"))
{
userinput = JOptionPane.showInputDialog("Enter users Last name");
break;
}
if (userinput.equals ("3"))
{userinput = JOptionPane.showInputDialog("Enter users emailAddress");

break;
}
if(userinput.equals ("4"))
{userinput = JOptionPane.showInputDialog("Enter users Birthdate");
break;
}
}


}
public static void Firstname()
{
String userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City \n4)Number");
}

public static void EAddress()
{
userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City \n4)Number");
}

public static void Birthyear()
{
userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City \n4)Number");
}


public static void Birthmonth()
{}
public static void Birthday()
{}*/


everytime i run it, it doesn't do anything!I commented everything out besides the first question because I want to get that to work first so i can understand it!I can't get the swapping to work!

sry that was the wrong code here is the code

import javax.swing.JOptionPane;

public class Lab6
{
public static void main (String[]args)
{

String [][]array = new String [4][5];

array[0][0] = "Miller";
array[0][1] = "Frank";
array[0][2] = "Roland";
array[0][3] = "Smith";
array[0][4] = "Laurel";
array[1][0] = "Joseph";
array[1][1] = "Michael";
array[1][2] = "Frank";
array[1][3] = "Jan";
array[1][4] = "Mary";
array[2][0] = "910 Auburn Avenue, McLean, VA, 7035551234";
array[2][1] = "1 York Road, Baltimore, MD, 4105551234";
array[2][2] = "346 Bellona Avenue, Lutherville, MD, 4435551234";
array[2][3] = "432 Burke Avenue, Towson, MD, 4105559876" ;
array[2][4] = "435 Saint Francis Avenue, Bowie, MD, 4435554567";
array[3][0] = "7035551234";
array[3][1] = "4105551234";
array[3][2] = "4435551234";
array[3][3] = "4105559876";
array[3][4] = "4435554567";


int look = 0;
String userinput =JOptionPane.showInputDialog("What Do you wish to replace?\n1)Last Name\n2)First Name\n3)Adress\n4)City\n5)Number");
int num =Integer.parseInt(userinput);
userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");

if (userinput.equals("1"))
{

String targetlastname = JOptionPane.showInputDialog("Enter users Last name");
String targetnewlast=JOptionPane.showInputDialog("enter users new Last name");

for(int x = 0; x < array.length;x++)

if(targetlastname.equals (array.length))
array[0][x]=targetnewlast;

} /* //output users info//
System.out.println("Edited users info.");
System.out.println(array [0][x]);
System.out.println(array [1][x]);
System.out.println(array [2][x]);
System.out.println(array [3][x]);
x = 4; */




if (userinput.equals(" 2"))
{

userinput =JOptionPane.showInputDialog("Enter users First name");
userinput =JOptionPane.showInputDialog("enter users new First name");



{
if (array [look][0].equals (userinput))
{

/*System.out.println();
//output users info//
System.out.println("Edited users info.");
System.out.println(array [0][x]);
System.out.println(array [1][x]);
System.out.println(array [2][x]);
System.out.println(array [3][x]);
x = 4;



/* }
if (userinput.equals ("3"))
{userinput = Integer.parseInt(JOptionPane.showInputDialog("Enter users Address");
userinput =Integer.parseInt(JOptionPane.showInputDialog("enter users new address");}
if(userinput.equals ("4"))
{userinput = Integer.parseInt(JOptionPane.showInputDialog("Enter users number");
userinput =Integer.parseInt(JOptionPane.showInputDialog("enter users new number");}
}
/* if (userinput.equals ("2"))
{
String searchlastname;

userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
if (userinput.equals ("1"))
searchlastname = JOptionPane.showInputDialog("Enter users Last name");

String newsearchlastname=JOptionPane.showInputDialog("enter users new Last name");
if (userinput.equals ("2"))
userinput = JOptionPane.showInputDialog("Enter users First name");
userinput =JOptionPane.showInputDialog("enter users new First name");
if (userinput.equals ("3"))
userinput = JOptionPane.showInputDialog("Enter users Address");
userinput =JOptionPane.showInputDialog("enter users new address");
if(userinput.equals ("4"))
userinput = JOptionPane.showInputDialog("Enter users number");
userinput =JOptionPane.showInputDialog("enter users new number");
}


if(userinput.equals ("3"))
{
String searchlastname;

userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
if (userinput.equals ("1"))
searchlastname = JOptionPane.showInputDialog("Enter users Last name");


String newsearchlastname=JOptionPane.showInputDialog("enter users new Last name");
if (userinput.equals ("2"))
userinput = JOptionPane.showInputDialog("Enter users First name");
userinput =JOptionPane.showInputDialog("enter users new First name");
if (userinput.equals ("3"))
userinput = JOptionPane.showInputDialog("Enter users Address");
userinput =JOptionPane.showInputDialog("enter users new address");
if(userinput.equals ("4"))
userinput = JOptionPane.showInputDialog("Enter users number");
userinput =JOptionPane.showInputDialog("enter users new number");
}
if(userinput.equals ("4"))
{
String searchlastname;

userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
if (userinput.equals ("1"))
searchlastname = JOptionPane.showInputDialog("Enter users Last name");

String newsearchlastname=JOptionPane.showInputDialog("enter users new Last name");
if (userinput.equals ("2"))
userinput = JOptionPane.showInputDialog("Enter users First name");
userinput =JOptionPane.showInputDialog("enter users new First name");
if (userinput.equals ("3"))
userinput = JOptionPane.showInputDialog("Enter users Address");
userinput =JOptionPane.showInputDialog("enter users new address");
if(userinput.equals ("4"))
userinput = JOptionPane.showInputDialog("Enter users number");
userinput =JOptionPane.showInputDialog("enter users new number");
}
if(userinput.equals ("5"))
{
String searchlastname;

userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
if (userinput.equals ("1"))
searchlastname = JOptionPane.showInputDialog("Enter users Last name");

String newsearchlastname=JOptionPane.showInputDialog("enter users new Last name");
if (userinput.equals ("2"))
userinput = JOptionPane.showInputDialog("Enter users First name");
userinput =JOptionPane.showInputDialog("enter users new First name");
if (userinput.equals ("3"))
userinput = JOptionPane.showInputDialog("Enter users Address");
userinput =JOptionPane.showInputDialog("enter users new address");
if(userinput.equals ("4"))
userinput = JOptionPane.showInputDialog("Enter users number");
userinput =JOptionPane.showInputDialog("enter users new number");*/
}
}
}
}
}














/*if(userinput.equals(targetlastName[000][005]))
userinput = targetlastName[000][005];}*/

Is This A Good Question/Topic? 0
  • +

Replies To: 2D Array in an Address Book

#2 asdbabil  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 241
  • Joined: 26-October 08

Re: 2D Array in an Address Book

Posted 21 October 2009 - 07:10 PM

Please post your code between [code] your code [code]

This post has been edited by asdbabil: 21 October 2009 - 07:11 PM

Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8315
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: 2D Array in an Address Book

Posted 21 October 2009 - 07:29 PM

And what is your question ?
Which error(s) do you get ?
Was This Post Helpful? 0
  • +
  • -

#4 cece7705  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 21-October 09

Re: 2D Array in an Address Book

Posted 21 October 2009 - 07:41 PM

 array[0][0] = "Miller";
    array[0][1] = "Frank";
    array[0][2] = "Roland";
    array[0][3] = "Smith";
    array[0][4] = "Laurel";
    array[1][0] = "Joseph";
    array[1][1] = "Michael";
    array[1][2] = "Frank";
    array[1][3] =  "Jan";
    array[1][4] = "Mary";
    array[2][0] = "910 Auburn Avenue, McLean, VA, 7035551234";
    array[2][1] = "1 York Road, Baltimore, MD, 4105551234";
    array[2][2] = "346 Bellona Avenue, Lutherville, MD, 4435551234";
    array[2][3] = "432 Burke Avenue, Towson, MD, 4105559876" ;
    array[2][4] = "435 Saint Francis Avenue, Bowie, MD, 4435554567";
    array[3][0] = "7035551234";
    array[3][1] = "4105551234";
    array[3][2] = "4435551234";
    array[3][3] = "4105559876";
    array[3][4] = "4435554567";
    

   int look = 0;
   String userinput =JOptionPane.showInputDialog("What Do you wish to replace?\n1)Last Name\n2)First Name\n3)Adress\n4)City\n5)Number");
   int num =Integer.parseInt(userinput);
    userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
      
   if (userinput.equals("1"))
   { 

   String targetlastname = JOptionPane.showInputDialog("Enter users Last name");
   String targetnewlast=JOptionPane.showInputDialog("enter users new Last name");
 
   for(int x = 0; x < array.length;x++)
 
    if(targetlastname.equals (array.length))
   array[0][x]=targetnewlast;
    
   }     /* //output users info//
        System.out.println("Edited users info.");
        System.out.println(array [0][x]);
        System.out.println(array [1][x]);
        System.out.println(array [2][x]);
        System.out.println(array [3][x]);
        x = 4; */

       
        
   
      if (userinput.equals(" 2"))
      {
        
        userinput =JOptionPane.showInputDialog("Enter users First name");
        userinput =JOptionPane.showInputDialog("enter users new First name");
        
        
        
    {
      if (array [look][0].equals (userinput))
      {
      
        /*System.out.println();
        //output users info//
        System.out.println("Edited users info.");
        System.out.println(array [0][x]);
        System.out.println(array [1][x]);
        System.out.println(array [2][x]);
        System.out.println(array [3][x]);
        x = 4;
        
        
        
     /* }
      if (userinput.equals ("3"))
      {userinput = Integer.parseInt(JOptionPane.showInputDialog("Enter users Address");
        userinput =Integer.parseInt(JOptionPane.showInputDialog("enter users new address");}
      if(userinput.equals ("4"))
      {userinput = Integer.parseInt(JOptionPane.showInputDialog("Enter users number");
        userinput =Integer.parseInt(JOptionPane.showInputDialog("enter users new number");}
   }
   /* if (userinput.equals ("2"))
    {
      String searchlastname;
  
   userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
      if (userinput.equals ("1"))
         searchlastname = JOptionPane.showInputDialog("Enter users Last name");
      
       String  newsearchlastname=JOptionPane.showInputDialog("enter users new Last name");
      if (userinput.equals ("2"))
        userinput = JOptionPane.showInputDialog("Enter users First name");
        userinput =JOptionPane.showInputDialog("enter users new First name");
      if (userinput.equals ("3"))
        userinput = JOptionPane.showInputDialog("Enter users Address");
        userinput =JOptionPane.showInputDialog("enter users new address");
      if(userinput.equals ("4"))
        userinput = JOptionPane.showInputDialog("Enter users number");
        userinput =JOptionPane.showInputDialog("enter users new number");
    }   
         
    
    if(userinput.equals ("3"))
     {
      String searchlastname;
  
   userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
      if (userinput.equals ("1"))
         searchlastname = JOptionPane.showInputDialog("Enter users Last name");
    
      
        String newsearchlastname=JOptionPane.showInputDialog("enter users new Last name");
      if (userinput.equals ("2"))
        userinput = JOptionPane.showInputDialog("Enter users First name");
        userinput =JOptionPane.showInputDialog("enter users new First name");
      if (userinput.equals ("3"))
        userinput = JOptionPane.showInputDialog("Enter users Address");
        userinput =JOptionPane.showInputDialog("enter users new address");
      if(userinput.equals ("4"))
        userinput = JOptionPane.showInputDialog("Enter users number");
        userinput =JOptionPane.showInputDialog("enter users new number");
    }  
    if(userinput.equals ("4"))
     {
      String searchlastname;
  
   userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
      if (userinput.equals ("1"))
         searchlastname = JOptionPane.showInputDialog("Enter users Last name");

        String newsearchlastname=JOptionPane.showInputDialog("enter users new Last name");
      if (userinput.equals ("2"))
        userinput = JOptionPane.showInputDialog("Enter users First name");
        userinput =JOptionPane.showInputDialog("enter users new First name");
      if (userinput.equals ("3"))
        userinput = JOptionPane.showInputDialog("Enter users Address");
        userinput =JOptionPane.showInputDialog("enter users new address");
      if(userinput.equals ("4"))
        userinput = JOptionPane.showInputDialog("Enter users number");
        userinput =JOptionPane.showInputDialog("enter users new number");
    }  
    if(userinput.equals ("5")) 
      {
      String searchlastname;
  
   userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
      if (userinput.equals ("1"))
         searchlastname = JOptionPane.showInputDialog("Enter users Last name");
     
        String newsearchlastname=JOptionPane.showInputDialog("enter users new Last name");
      if (userinput.equals ("2"))
        userinput = JOptionPane.showInputDialog("Enter users First name");
        userinput =JOptionPane.showInputDialog("enter users new First name");
      if (userinput.equals ("3"))
        userinput = JOptionPane.showInputDialog("Enter users Address");
        userinput =JOptionPane.showInputDialog("enter users new address");
      if(userinput.equals ("4"))
        userinput = JOptionPane.showInputDialog("Enter users number");
        userinput =JOptionPane.showInputDialog("enter users new number");*/
    }
  }
  }
   }
   }
  
[\code]

I can't seem to change the old last name to the new. I commented everything else out because I wanted to make sure i understand how to do the first one.i know there is a for loop involved
 but i can't get it right.The program is suppose to read for the array.



  


  


[code]  array[0][0] = "Miller";
	array[0][1] = "Frank";
	array[0][2] = "Roland";
	array[0][3] = "Smith";
	array[0][4] = "Laurel";
	array[1][0] = "Joseph";
	array[1][1] = "Michael";
	array[1][2] = "Frank";
	array[1][3] =  "Jan";
	array[1][4] = "Mary";
	array[2][0] = "910 Auburn Avenue, McLean, VA, 7035551234";
	array[2][1] = "1 York Road, Baltimore, MD, 4105551234";
	array[2][2] = "346 Bellona Avenue, Lutherville, MD, 4435551234";
	array[2][3] = "432 Burke Avenue, Towson, MD, 4105559876";
	array[2][4] = "435 Saint Francis Avenue, Bowie, MD, 4435554567";
	array[3][0] = "7035551234";
	array[3][1] = "4105551234";
	array[3][2] = "4435551234";
	array[3][3] = "4105559876";
	array[3][4] = "4435554567";
	

   int look = 0;
   String userinput =JOptionPane.showInputDialog("What Do you wish to replace?\n1)Last Name\n2)First Name\n3)Adress\n4)City\n5)Number");
   int num =Integer.parseInt(userinput);
	userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
	  
   if (userinput.equals("1"))
   { 

   String targetlastname = JOptionPane.showInputDialog("Enter users Last name");
   String targetnewlast=JOptionPane.showInputDialog("enter users new Last name");
 
   for(int x = 0; x < array.length;x++)
 
	if(targetlastname.equals (array.length))
   array[0][x]=targetnewlast;
	
   }	 /* //output users info//
		System.out.println("Edited users info.");
		System.out.println(array [0][x]);
		System.out.println(array [1][x]);
		System.out.println(array [2][x]);
		System.out.println(array [3][x]);
		x = 4; */

	   
		
   
	  if (userinput.equals(" 2"))
	  {
		
		userinput =JOptionPane.showInputDialog("Enter users First name");
		userinput =JOptionPane.showInputDialog("enter users new First name");
		
		
		
	{
	  if (array [look][0].equals (userinput))
	  {
	  
		/*System.out.println();
		//output users info//
		System.out.println("Edited users info.");
		System.out.println(array [0][x]);
		System.out.println(array [1][x]);
		System.out.println(array [2][x]);
		System.out.println(array [3][x]);
		x = 4;
		
		
		
	 /* }
	  if (userinput.equals ("3"))
	  {userinput = Integer.parseInt(JOptionPane.showInputDialog("Enter users Address");
		userinput =Integer.parseInt(JOptionPane.showInputDialog("enter users new address");}
	  if(userinput.equals ("4"))
	  {userinput = Integer.parseInt(JOptionPane.showInputDialog("Enter users number");
		userinput =Integer.parseInt(JOptionPane.showInputDialog("enter users new number");}
   }
   /* if (userinput.equals ("2"))
	{
	  String searchlastname;
  
   userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
	  if (userinput.equals ("1"))
		 searchlastname = JOptionPane.showInputDialog("Enter users Last name");
	  
	   String  newsearchlastname=JOptionPane.showInputDialog("enter users new Last name");
	  if (userinput.equals ("2"))
		userinput = JOptionPane.showInputDialog("Enter users First name");
		userinput =JOptionPane.showInputDialog("enter users new First name");
	  if (userinput.equals ("3"))
		userinput = JOptionPane.showInputDialog("Enter users Address");
		userinput =JOptionPane.showInputDialog("enter users new address");
	  if(userinput.equals ("4"))
		userinput = JOptionPane.showInputDialog("Enter users number");
		userinput =JOptionPane.showInputDialog("enter users new number");
	}   
		 
	
	if(userinput.equals ("3"))
	 {
	  String searchlastname;
  
   userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
	  if (userinput.equals ("1"))
		 searchlastname = JOptionPane.showInputDialog("Enter users Last name");
	
	  
		String newsearchlastname=JOptionPane.showInputDialog("enter users new Last name");
	  if (userinput.equals ("2"))
		userinput = JOptionPane.showInputDialog("Enter users First name");
		userinput =JOptionPane.showInputDialog("enter users new First name");
	  if (userinput.equals ("3"))
		userinput = JOptionPane.showInputDialog("Enter users Address");
		userinput =JOptionPane.showInputDialog("enter users new address");
	  if(userinput.equals ("4"))
		userinput = JOptionPane.showInputDialog("Enter users number");
		userinput =JOptionPane.showInputDialog("enter users new number");
	}  
	if(userinput.equals ("4"))
	 {
	  String searchlastname;
  
   userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
	  if (userinput.equals ("1"))
		 searchlastname = JOptionPane.showInputDialog("Enter users Last name");

		String newsearchlastname=JOptionPane.showInputDialog("enter users new Last name");
	  if (userinput.equals ("2"))
		userinput = JOptionPane.showInputDialog("Enter users First name");
		userinput =JOptionPane.showInputDialog("enter users new First name");
	  if (userinput.equals ("3"))
		userinput = JOptionPane.showInputDialog("Enter users Address");
		userinput =JOptionPane.showInputDialog("enter users new address");
	  if(userinput.equals ("4"))
		userinput = JOptionPane.showInputDialog("Enter users number");
		userinput =JOptionPane.showInputDialog("enter users new number");
	}  
	if(userinput.equals ("5")) 
	  {
	  String searchlastname;
  
   userinput = JOptionPane.showInputDialog("Look up the user by\n1)Last Name\n2)Adress\n3)City\n4)Number");
	  if (userinput.equals ("1"))
		 searchlastname = JOptionPane.showInputDialog("Enter users Last name");
	 
		String newsearchlastname=JOptionPane.showInputDialog("enter users new Last name");
	  if (userinput.equals ("2"))
		userinput = JOptionPane.showInputDialog("Enter users First name");
		userinput =JOptionPane.showInputDialog("enter users new First name");
	  if (userinput.equals ("3"))
		userinput = JOptionPane.showInputDialog("Enter users Address");
		userinput =JOptionPane.showInputDialog("enter users new address");
	  if(userinput.equals ("4"))
		userinput = JOptionPane.showInputDialog("Enter users number");
		userinput =JOptionPane.showInputDialog("enter users new number");*/
	}
  }
  }
   }
   }
  





  


  
  



sry!this is the code!


I can't seem to change the old last name to the new. I commented everything else out because I wanted to make sure i understand how to do the first one.i know there is a for loop involved
but i can't get it right.The program is suppose to read for the array.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1