    //*********************************************************
    /** Determine if a card number is valid
    *
    *   The basic algorithm is to double alternate digits
    *   starting at the right end of the string and then
    *   add the resulting digits. If the sum is a multiple
    *   of 10, the number is valid
    */
    //*********************************************************
    private boolean validate ( String cardNo )
    {
      // ensure that all characters are digits
        for ( int i = 0; i < cardNo.length(); i++ )
        {
            char ch = cardNo.charAt ( i );
            if ( !Character.isDigit ( ch ) )
            {
                return false;
            }
        }

      // step 1 is to double alternate digits,
      // starting at the right side
      // and insert them into the output string
      // we insert non-alternate digits as is
        StringBuffer sb1 = new StringBuffer();

        boolean alternate = false;

        for ( int i = cardNo.length() - 1; i >= 0; i-- )
        {
            char ch = cardNo.charAt ( i );
            if ( alternate == true )
            {
                int j = Character.getNumericValue ( ch );
                j *= 2;
                String s = String.valueOf ( j );
                if ( s.length() == 2 )
                    sb1.append ( s.charAt ( 1 ) );
                sb1.append ( s.charAt ( 0 ) );
                alternate = false;
            }
            else
            {
                sb1.append ( ch );
                alternate = true;
            }
        }

      // step 2 is to add up all of the digits
        String s2 = new String ( sb1 );

        int sum = 0;

        for ( int i = 0; i < s2.length(); i++ )
        {
            char ch = s2.charAt ( i );

            int j = Character.getNumericValue ( ch );
            if ( j < 0 )
            {
                return false;
            }
            else
            {
                sum += j;
            }
        }

      // step three is to see if it's evenly divisble by 10
        if ( sum % 10 == 0 )
            return true;
        else
            return false;
    }

