I am trying to figure out how to concat two strings if certain conditions are met or not met. Say I were to enter a string, and the string did not contain any letters. I would then prompt the program to add 007 at the end of the string, and if I were to include numbers in the string in the first place it would output what I entered in the first place. I have tried the following sequences below, but have not found anything that works properly.
Say I entered John1... I want it to output John1.
If I were to enter John... Then I would want it to output John007.
Or if I were to enter Area51Games... Then I would want it to output Area51Games.
Does anyone have any helpful advice to help me solve my problem, because isLetter, and isDigit just aren't working for me.
//My code
import javax.swing.JOptionPane;
public class Word {
public static void main(String[] args){
String word = "";
word = JOptionPane.showInputDialog("Enter a word: ");
valid(word);
}//end main method
public static void valid(String input){
String number = "007";
String output = "";
for(int i = 0; i < input.length(); i++){
// else if(!Character.isLetter(output.charAt(i))){output+= number;break;}//end 007 else if
// else if(Character.isLetter(output.charAt(i))){output+=n umber;break;}//end 007 else if
// else if(!Character.isDigit(output.charAt(i))){output+=n umber;break;}//end 007 else if
// else if(Character.isDigit(output.charAt(i))){output+=nu mber;break;}//end 007 else if
// else if(!Character.isLetter(input.charAt(i))){output+=n umber;break;}//end 007 else if
// else if(Character.isLetter(input.charAt(i))){output += number;break;}//end 007 else if
// else if(!Character.isDigit(input.charAt(i))){output+=nu mber;break;}//end 007 else if
// else if(Character.isDigit(input.charAt(i))){output+=num ber;break;}//end 007 else if
}//end for loop
JOptionPane.showMessageDialog(null,"The output is: " + output);
}//end valid method
}//end Word Class