public static String addLuhnDigit(String number){
  char[] digits={'1','2','3','4','5','6','7','8','9','0'};
  int c=number.length();
  StringBuffer tryNumber=new StringBuffer(number + digits[0]);
  int i;
  for (i=0; i < 10; i++) {
    tryNumber.setCharAt(c,digits[i]);
    if (luhnCheck(tryNumber.toString()))     break;
  }
  return tryNumber.toString();
}

public static String addLuhnDigit ( String number ) { char [ ] digits = { '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '0' } ; int c = number . length ( ) ; StringBuffer tryNumber = new StringBuffer ( number + digits [ 0 ] ) ; int i ; for ( i = 0 ; i < 10 ; i ++ ) { tryNumber . setCharAt ( c , digits [ i ] ) ; if ( luhnCheck ( tryNumber . toString ( ) ) ) break ; } return tryNumber . toString ( ) ; }
returns number with the appropriate digit appended so that is passes a " luhncheck " .
