import javax.swing.*;
public class xm3
{
public static void main(String[] args)
{
String[][] addressBook =
{ {"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"}, //state
{"7035551234", "4105551234", "4435551234", "4105559876", "4435554567"}
};
String inputStr = "";
String[] choices = {"first name", "last name", "address", "zip code"};
int input = Integer.parseInt(JOptionPane.showInputDialog("What do you wish to replace?\n" +
"1. " + choices[0] + "\n" +
"2. " + choices[1] + "\n" +
"3. " + choices[2] + "\n" +
"4. " + choices[3] + "\n"));
if(input == 1) {
replace();
}
else if(input == 2) {
replace();
}
else if(input == 3) {
replace();
}
else if(input == 4) {
replace();
}
else{
System.out.println("error");
System.exit(0);
}
}
public static void replace() {
String[] choices = {"first name", "last name", "address", "zip code"};
int input = Integer.parseInt(JOptionPane.showInputDialog("Look up the user by: \n" +
"1. " + choices[0] + "\n" +
"2. " + choices[1] + "\n" +
"3. " + choices[2] + "\n" +
"4. " + choices[3] + "\n"));
if (input == 1) {
for(int rows = 0; rows < 6; rows++) {
if(rows == input) {
for(int columns = 0; columns < 5; columns++) {
tempStr = addressBook[rows][columns];
if(tempStr.equalsIgnoreCase(infoToBeReplaced)) {
addressBook[rows][columns] = replacingInfo;
}
}
}
}
}
}
}