Hi nikkirose7,
Below is a proposed solution for you. I took out the showdialog calls since I am not using a GUI frame in the example and figured a scanner might be easier to understand at this point. As you can see I simply collect the name and address, split the name and pull off the first character on each part of the name, then loop through the address adding only the digits. The result is your ID.
CODE
import javax.swing.*;
import java.util.Scanner;
public class constructid
{
public static void main(String[] args)
{
String nameString;
String addressString;
String id = "";
// Use the scanner to setup reading input from user.
Scanner s = new Scanner(System.in);
// Prompt for the user's name and their address
System.out.print("Enter your full name: ");
nameString = s.nextLine();
System.out.print("Enter your full address: ");
addressString = s.nextLine();
// Split the name on the spaces and take the first character of each piece
String[] pieces = nameString.split(" ");
for (String piece : pieces) {
id += Character.toString(piece.charAt(0));
}
// Loop through the address looking for digits (using isDigit of the Character class)
for (int i = 0; i < addressString.length(); i++) {
if (Character.isDigit(addressString.charAt(i))) {
id += Character.toString(addressString.charAt(i));
}
}
System.out.println(id);
}
}
Read through the in code comments to see what I am doing where. Hopefully it is pretty straight forward for you and that it is what you were asking for. Of course if you are building a GUI and everything you can go about collecting the information anyway you like.
Enjoy!
"At DIC we be coding ninjas!"