13 Replies - 730 Views - Last Post: 10 March 2013 - 10:59 PM Rate Topic: -----

#1 Guille  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 20
  • Joined: 21-October 12

Credit Card Validation, User warnings(few/many-digits. )

Posted 09 March 2013 - 09:49 PM

Hi, This is my code, and i'm having problems with the validity outputs... as you can read in the description, i am to use the things i'm asked to used... sizeInvalid, prefixIsInvalid, and digitsAreValid, honestly i have no clue of how to do this.. i tried somethings but they didn't work.. i you see in my code, i tried using the if statements to get the output for the size.. but it doesn't seem to work..and if you could give me some feed back on the code overall.. it will be greatly appreciated.


You are to do Machine Project 5.31 from the text, where you are to use a for loop to test your logic
on 11 different sample card numbers. The code for the main loop in this application is as follows:
for (count = 0; count < TOTAL_TRIALS; count++)
{
System.out.print("Enter a card number: ");
cardNumber = keyboard.nextLong( );
keyboard.nextLine( );
if (isValid(cardNumber))
System.out.println("the number is valid.");
else
System.out.println("the number in not valid.");
where the 11 sample runs (Note: TOTAL_TRIALS is a global constant, a final value) are as follows:
Enter a card number: 431189543102
There are too few digits in the card, so the number is not valid.
Enter a card number: 59327698001231327
There are too many digits in the card, so the number is not valid.
Enter a card number: 8431998650521231
The card is not corporate, so the number is not valid.
Enter a card number: 3719282493103238
The card is American Express, and the number is valid.
Enter a card number: 3763098416524
The card is American Express, and the number is not valid.
Enter a card number: 4388576018410707
The card is Visa, and the number is valid.
Enter a card number: 4388576018402625
The card is Visa, and the number is not valid.
Enter a card number: 51873622090437
The card is MasterCard, and tisValidíhe number is valid.
Enter a card number: 51872364091945
The card is MasterCard, and the number is not valid.
Enter a card number: 6031451987218208
The card is Discover, and the number is valid.
Enter a card number: 6224501893125
The card is Discover, and the number is not valid.
You are to use the same data I did for the sample runs in order to test the logic of your project.

Here is is how the three tests for invalidity are done:
 the invalid size test result is gotten with a call to the boolean function sizeIsInvalid. The single
argument required of this function is the value of the int variable size (it doesnít need the value
of cardNumber!). If an invalid size is found, the function should display an appropriate output
message using a System.out.print (not println, please!) statement.
 the invalid prefix test result is gotten with a call to the boolean method prefixIsInvalid. This
method requires the cardNumber and size. It will display text about the cardís company when
false is returned (the card is valid) or that the card has no company (when true is returned)
 If the card has the proper number of digits and belongs to one of the four corporations, the
method digitsAreValid is called. This method checks whether or not the sum of the odd and
even digit sums passes the Luhn algorithm, as described in the text. There are no display
responsibilities required of the method digitsAreValid


import java.util.Scanner;

/** This Program checks the validity of a credit card number.
 * Its main purpose is to prompt the user to enter a Credit card 
 * number and display whether the number is valid or invalid*/


public class Project1a
{


public static void main(String[] args) 
	{
	    Scanner keyboard = new Scanner(System.in);
	
		int  TOTAL_TRIALS = 11;
		int count;
		for (count = 0;count<TOTAL_TRIALS; count++)
	    {
	    
	    System.out.print("Enter a Card Number : ");
	    long cardNumber = keyboard.nextLong();
	    keyboard.nextLine();
	    if (isValid(cardNumber) == true) 
	    {
	        System.out.println("the number is Valid.");
	    } 
	    if (getSize(cardNumber)> 16)
	    {
			System.out.println("There are to many digits in the card, so the number is not valid. ");
		}
	    else if (getSize(cardNumber)<16)
	    {
	    	System.out.println("There are too few digits in the card, so the number is not valid.");
	    }
	    else 
	    {
	        System.out.println("the number is not valid.");
	    }
	    
	    }
		keyboard.close();
	}

/** Return true if the card number is valid*/
    public static boolean isValid(long number) 
    {
        int total = sumOfDoubleEvenPlace(number) + sumOfOddPlace(number);
        if ((total % 10 == 0) && (prefixMatched(number, 1) == true)) 
        {
            return true;
        } 
        else 
        {
            return false;
        }
    }
    
    /** Get the result Step 2*/
    public static int getDigit(int number) 
    {
        if (number <= 9) 
        {
            return number;
        } 
        else 
        {
            int firstDigit = number % 10;
            int secondDigit = (int) (number / 10);

            return firstDigit + secondDigit;
        }
    }
    
    /** Return this number if it is a single digit, otherwise,
	 * return the sum of the two digits*/   
    public static int sumOfOddPlace(long number) 
    {
        int result = 0;
        while (number > 0) 
        {
            result += (int) (number % 10);
            number = number / 100;
        }
        return result;
    }

    /** Return of sum of odd-place digits in number*/
    public static int sumOfDoubleEvenPlace(long number)
    {
        int result = 0;
        long temp = 0;

        while (number > 0) 
        {
            temp = number % 100;
            result += getDigit((int) (temp / 10) * 2);
            number = number / 100;
        }
        return result;
    }
    
    /** Return true if the digit d is the prefix for the number*/
    public static boolean prefixMatched(long number, int d) 
    {
        if ((getPrefix(number, d) == 37)
        		|| (getPrefix(number, d) == 4)
                || (getPrefix(number, d) == 5)
                || (getPrefix(number, d) == 6)) 
        {
            if (getPrefix(number, d) == 37
            		) 
            {
                System.out.print("The Card is American Express, and ");   
            } 
            else if (getPrefix(number, d) == 4) 
            {
                System.out.print("The Card is Visa, and ");
            } 
            else if (getPrefix(number, d) == 5) {
                System.out.print("The Card is Master, and ");
            } 
            else if (getPrefix(number, d) == 6) 
            {
                System.out.print("The Card is Discover Card, and  ");
            }
            return true;           
        	} 
        	else
        	{
        		System.out.print("The Number is not corporate, so ");
        	}
		return false;
       
        }
    
    /**Return the number of digits in d*/
    public static int getSize(long d) 
    {
        int count = 0;
        while (d > 0) 
        {
            d = d / 10;
            count++;
        }
        return count;
    }
    /**Return the first k number of digits from number. If the
	 * number of digits in number is less than k, return number.*/
    public static long getPrefix(long number, int k) 
    {
        if (getSize(number) < k) 
        {
            return number;
        } 
        else 
        {
            int size = (int) getSize(number);
            for (int i = 0; i < (size - k); i++) 
            {
                number = number / 10;
            }
            return number;
        }
    }   
}



Is This A Good Question/Topic? 0
  • +

Replies To: Credit Card Validation, User warnings(few/many-digits. )

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10397
  • View blog
  • Posts: 38,471
  • Joined: 27-December 08

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 09 March 2013 - 10:31 PM

What specific problems or errors are you encountering?
Was This Post Helpful? 0
  • +
  • -

#3 Guille  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 20
  • Joined: 21-October 12

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 09 March 2013 - 10:46 PM

View Postmacosxnerd101, on 09 March 2013 - 10:31 PM, said:

What specific problems or errors are you encountering?


the code works fine.. well at least that is what i think.. but, im not able to think of a way to use this sizeInvalid, prefixIsInvalid, and digitsAreValid, in order to check for the validity of the credit cards..

as you can see in my description.. my code has to be able to show this output.

Enter a card number: 431189543102
There are too few digits in the card, so the number is not valid.
Enter a card number: 59327698001231327
There are too many digits in the card, so the number is not valid.
Enter a card number: 8431998650521231
The card is not corporate, so the number is not valid.
Enter a card number: 3719282493103238
The card is American Express, and the number is valid.
Enter a card number: 3763098416524
The card is American Express, and the number is not valid.
Enter a card number: 4388576018410707
The card is Visa, and the number is valid.
Enter a card number: 4388576018402625
The card is Visa, and the number is not valid.
Enter a card number: 51873622090437
The card is MasterCard, and tisValidíhe number is valid.
Enter a card number: 51872364091945
The card is MasterCard, and the number is not valid.
Enter a card number: 6031451987218208
The card is Discover, and the number is valid.
Enter a card number: 6224501893125
The card is Discover, and the number is not valid.


...

and also im not sure how to make the prefix for the american express to be
 /** Return true if the digit d is the prefix for the number*/
    public static boolean prefixMatched(long number, int d) 
    {
        if ((getPrefix(number, d) == 37)
        		|| (getPrefix(number, d) == 4)
                || (getPrefix(number, d) == 5)
                || (getPrefix(number, d) == 6)) 
        {
            if (getPrefix(number, d) == 37
            		) 
            {
                System.out.print("The Card is American Express, and ");   
            } 
            else if (getPrefix(number, d) == 4) 
            {
                System.out.print("The Card is Visa, and ");
            } 
            else if (getPrefix(number, d) == 5) {
                System.out.print("The Card is Master, and ");
            } 
            else if (getPrefix(number, d) == 6) 
            {
                System.out.print("The Card is Discover Card, and  ");
            }
            return true;           
        	} 
        	else
        	{
        		System.out.print("The Number is not corporate, so ");
        	}
		return false;
       
        }


i put 37 there.. but when i check for the validity of a american express card, i get this output.
"The Number is not corporate, so the number is not valid." instead of this " The card is American Express, and the number is valid."..
Was This Post Helpful? 0
  • +
  • -

#4 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2657
  • View blog
  • Posts: 11,207
  • Joined: 20-September 08

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 10 March 2013 - 01:24 PM

See http://technojeeves....hn-algo-in-java
Was This Post Helpful? 1
  • +
  • -

#5 Guille  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 20
  • Joined: 21-October 12

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 10 March 2013 - 01:34 PM

View Postg00se, on 10 March 2013 - 01:24 PM, said:



yeah.. thank you,but im not having problems with the code.. it soo far does what it needs to do.. i just cant figure out how to get the code to give me these outputs..

Enter a card number: 431189543102
There are too few digits in the card, so the number is not valid.
Enter a card number: 59327698001231327
There are too many digits in the card, so the number is not valid.
Enter a card number: 8431998650521231
The card is not corporate, so the number is not valid.
Enter a card number: 3719282493103238
The card is American Express, and the number is valid.
Enter a card number: 3763098416524
The card is American Express, and the number is not valid.
Enter a card number: 4388576018410707
The card is Visa, and the number is valid.
Enter a card number: 4388576018402625
The card is Visa, and the number is not valid.
Enter a card number: 51873622090437
The card is MasterCard, and tisValidíhe number is valid.
Enter a card number: 51872364091945
The card is MasterCard, and the number is not valid.
Enter a card number: 6031451987218208
The card is Discover, and the number is valid.
Enter a card number: 6224501893125
The card is Discover, and the number is not valid.
Was This Post Helpful? 0
  • +
  • -

#6 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2657
  • View blog
  • Posts: 11,207
  • Joined: 20-September 08

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 10 March 2013 - 02:48 PM

Quote

yeah.. thank you,but im not having problems with the code.. it soo far does what it needs to do.. i just cant figure out how to get the code to give me these outputs..
There seems to be some contradiction there. If you're not having problems with the code, then ... problem solved
Was This Post Helpful? 0
  • +
  • -

#7 Guille  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 20
  • Joined: 21-October 12

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 10 March 2013 - 03:00 PM

View Postg00se, on 10 March 2013 - 02:48 PM, said:

Quote

yeah.. thank you,but im not having problems with the code.. it soo far does what it needs to do.. i just cant figure out how to get the code to give me these outputs..
There seems to be some contradiction there. If you're not having problems with the code, then ... problem solved


im really sorry about that..
i have a problem.
this is my code
import java.util.Scanner;
/** Name: Guillermo Remache   / Patrick Tsang
 * Course: CTEC 206-M01
 * Project: Machine Project 1 a */

/** This Program checks the validity of a credit card number.
 * Its main purpose is to prompt the user to enter a Credit card 
 * number and display whether the number is valid or invalid*/


public class Project1a
{


public static void main(String[] args) 
	{
	    Scanner keyboard = new Scanner(System.in);
	
		int  TOTAL_TRIALS = 11;
		int count;
		for (count = 0;count<TOTAL_TRIALS; count++)
	    {
	    
	    System.out.print("Enter a Card Number: ");
	    long cardNumber = keyboard.nextLong();
	    keyboard.nextLine();
	    if (isValid(cardNumber) == true) 
	    {
	        System.out.println("the number is Valid.");
	    } 
	    else if (getSize(cardNumber)> 16)
	    {
			System.out.print("There are to many digits in the card, so the number is not valid.\n ");
		}
	    else if (getSize(cardNumber)<13)
	    {
	    	System.out.print("There are too few digits in the card, so the number is not valid.\n");
	    }
	    else

	    	if (prefixMatched(0, 0)== false)
	    {
	    	System.out.print("The card is not corporate, so  the card is not valid. \n");
	    }
	    else
	    {
	        System.out.println(" the number is not valid.");
	    }
	    }
		keyboard.close();
	}

/** Return true if the card number is valid*/
    private static boolean isValid(long number) 
    {
        int total = sumOfDoubleEvenPlace(number) + sumOfOddPlace(number);
        if ((total % 10 == 0) && (prefixMatched(number, 1) == true)) 
        {
            return true;
        } 
        else 
        {
            return false;
        }
    }
    
    /** Get the result Step 2*/
    private static int getDigit(int number) 
    {
        if (number <= 9) 
        {
            return number;
        } 
        else 
        {
            int firstDigit = number % 10;
            int secondDigit = (int) (number / 10);

            return firstDigit + secondDigit;
        }
    }
    
    /** Return this number if it is a single digit, otherwise,
	 * return the sum of the two digits*/   
    private static int sumOfOddPlace(long number) 
    {
        int result = 0;
        while (number > 0) 
        {
            result += (int) (number % 10);
            number = number / 100;
        }
        return result;
    }

    /** Return of sum of odd-place digits in number*/
    private static int sumOfDoubleEvenPlace(long number)
    {
        int result = 0;
        long temp = 0;

        while (number > 0) 
        {
            temp = number % 100;
            result += getDigit((int) (temp / 10) * 2);
            number = number / 100;
        }
        return result;
    }
    
    /** Return true if the digit d is the prefix for the number*/
    private static boolean prefixMatched(long number, int d) 
    {
        if ((getPrefix(number, d) == 3)
        		|| (getPrefix(number, d) == 4)
                || (getPrefix(number, d) == 5)
                || (getPrefix(number, d) == 6)) 
        {
            if (getPrefix(number, d) == 3) 
            {
                System.out.print("The Card is American Express, and ");   
            } 
            else if (getPrefix(number, d) == 4) 
            {
                System.out.print("The Card is Visa, and ");
            } 
            else if (getPrefix(number, d) == 5) {
                System.out.print("The Card is Master, and ");
            } 
            else if (getPrefix(number, d) == 6) 
            {
                System.out.print("The Card is Discover Card, and  ");
            }
            return true;           
        	}
        else 
        {	
        }
		return false;
        }
    
    /**Return the number of digits in d*/
    private static int getSize(long d) 
    {
        int count = 0;
        while (d > 0) 
        {
            d = d / 10;
            count++;
        }
        return count;
    }
    /**Return the first k number of digits from number. If the
	 * number of digits in number is less than k, return number.*/
    private static long getPrefix(long number, int k) 
    {
        if (getSize(number) < k) 
        {
            return number;
        } 
        else 
        {
            int size = (int) getSize(number);
            for (int i = 0; i < (size - k); i++) 
            {
                number = number / 10;
            }
            return number;
        }
    }   
}



So far it works up to the point where i input a credit card number and it tells me if it is valid with he following outputs ..
Enter a card number: 431189543102
There are too few digits in the card, so the number is not valid.
Enter a card number: 59327698001231327
There are too many digits in the card, so the number is not valid.
Enter a card number: 8431998650521231
The card is not corporate, so the number is not valid.
Enter a card number: 3719282493103238
The card is American Express, and the number is valid.

but i cannot make it so it tells me the following..
Enter a card number: 3763098416524
The card is <card name>, and the number is not valid.

thank you for your help
Was This Post Helpful? 0
  • +
  • -

#8 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2657
  • View blog
  • Posts: 11,207
  • Joined: 20-September 08

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 10 March 2013 - 03:20 PM

Quote

but i cannot make it so it tells me the following..
... which is why i posted the link. If you use it, it will tell you
Was This Post Helpful? 0
  • +
  • -

#9 Guille  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 20
  • Joined: 21-October 12

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 10 March 2013 - 03:35 PM

View Postg00se, on 10 March 2013 - 03:20 PM, said:

Quote

but i cannot make it so it tells me the following..
... which is why i posted the link. If you use it, it will tell you


there is nothing there that tells me how to or give me an idea on how to write the code so it tells me that the ex. The card is Discovery a, and the number is not valid..

i just need help with that
Was This Post Helpful? 0
  • +
  • -

#10 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2657
  • View blog
  • Posts: 11,207
  • Joined: 20-September 08

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 10 March 2013 - 04:42 PM

Quote

there is nothing there that tells me how to or give me an idea on how to write the code so it tells me that the ex. The card is Discovery a, and the number is not valid..
Well it will tell you about whether the number is valid. As for the Discovery thing, look at the comments for the prefixMatched method and the getPrefix method. They don't actually tally
Was This Post Helpful? 0
  • +
  • -

#11 Guille  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 20
  • Joined: 21-October 12

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 10 March 2013 - 07:38 PM

View Postg00se, on 10 March 2013 - 04:42 PM, said:

Quote

there is nothing there that tells me how to or give me an idea on how to write the code so it tells me that the ex. The card is Discovery a, and the number is not valid..
Well it will tell you about whether the number is valid. As for the Discovery thing, look at the comments for the prefixMatched method and the getPrefix method. They don't actually tally


i need to write this rule,

if prefixMatched is true and if the size if the cardNumber is between 13 and 15 digits, then System.out.print("The card is<card type>, and is not valid");



so far when prefixMatched is true it gives me the folling out..

"The Card is <card Type>, and the Number is valid,

and if prefixMatched is false it gives me the following output..
" the card is not corporate, so the card is not valid"

and when there are few digists <13 and too many digits >16 it tells me
" Theere are too many or too few digits, so the number is invalid."

i would reallly apreciate you help..
thank you again.
Was This Post Helpful? 0
  • +
  • -

#12 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10397
  • View blog
  • Posts: 38,471
  • Joined: 27-December 08

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 10 March 2013 - 09:35 PM

Read your code. Why are you passing 0 as both parameters to the prefixMatched() method? It doesn't make sense.

Quote

if prefixMatched is true and if the size if the cardNumber is between 13 and 15 digits, then System.out.print("The card is<card type>, and is not valid");

Then literally write this.

Also, in the future, please do not contact me via PM requesting help. I spend a lot of time on the forums and help as many people as I can, so it's pointless to PM me.
Was This Post Helpful? 0
  • +
  • -

#13 Guille  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 20
  • Joined: 21-October 12

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 10 March 2013 - 10:04 PM

For all those who helped me, if they did try,
and for people interested in this code..
i finally got it to work.. im still not sure how it work and why , but it works now..
import java.util.Scanner;
/
 * Project: Machine Project 1 a */

/** This Program checks the validity of a credit card number.
 * Its main purpose is to prompt the user to enter a Credit card 
 * number and display whether the number is valid or invalid*/


public class Project1a
{


public static void main(String[] args) 
	{
	    Scanner keyboard = new Scanner(System.in);
	
		int  TOTAL_TRIALS = 11;
		int count;
		for (count = 0;count<TOTAL_TRIALS; count++)
	    {
	    
	    System.out.print("Enter a Card Number: ");
	    long cardNumber = keyboard.nextLong();
	    keyboard.nextLine();
	    if (isValid(cardNumber) == true) 
	    {
	        System.out.println("the number is Valid.");
	    } 
	    
	    else if (getSize(cardNumber)> 16)
	    {
			System.out.print("There are to many digits in the card, so the number is not valid.\n");
		}
	    	else if (getSize(cardNumber)<13)
	    {
	    	System.out.print("There are too few digits in the card, so the number is not valid.\n");
	    }
	    	else 
				if (prefixMatched(cardNumber, 1)== false)
		    {
		    	System.out.print("The card is not corporate, so  the card is not valid.\n");
		    }
	
	    else
	    {
	    	
	    System.out.println("the number is not valid.");
	    }
	    	
	    	
	    }
		keyboard.close();
	}

/** Return true if the card number is valid*/
    private static boolean isValid(long number) 
    {
        int total = sumOfDoubleEvenPlace(number) + sumOfOddPlace(number);
        if ((total % 10 == 0) && (prefixMatched(number, 1) == true)) 
        {
            return true;
        } 
        else 
        {
            return false;
        }
    }
    
    /** Get the result Step 2*/
    private static int getDigit(int number) 
    {
        if (number <= 9) 
        {
            return number;
        } 
        else 
        {
            int firstDigit = number % 10;
            int secondDigit = (int) (number / 10);

            return firstDigit + secondDigit;
        }
    }
    
    /** Return this number if it is a single digit, otherwise,
	 * return the sum of the two digits*/   
    private static int sumOfOddPlace(long number) 
    {
        int result = 0;
        while (number > 0) 
        {
            result += (int) (number % 10);
            number = number / 100;
        }
        return result;
    }

    /** Return of sum of odd-place digits in number*/
    private static int sumOfDoubleEvenPlace(long number)
    {
        int result = 0;
        long temp = 0;

        while (number > 0) 
        {
            temp = number % 100;
            result += getDigit((int) (temp / 10) * 2);
            number = number / 100;
        }
        return result;
    }
    
    /** Return true if the digit d is the prefix for the number*/
    private static boolean prefixMatched(long number, int d) 
    {
        if ((getPrefix(number, d) == 3)
        		|| (getPrefix(number, d) == 4)
                || (getPrefix(number, d) == 5)
                || (getPrefix(number, d) == 6)) 
        {
            if (getPrefix(number, d) == 3) 
            {
                System.out.print("The Card is American Express, and ");   
            } 
            else if (getPrefix(number, d) == 4) 
            {
                System.out.print("The Card is Visa, and ");
            } 
            else if (getPrefix(number, d) == 5) {
                System.out.print("The Card is Mastercard, and ");
            } 
            else if (getPrefix(number, d) == 6) 
            {
                System.out.print("The Card is Discover Card, and  ");
            }
            return true;           
        	}
        else 
        {
        	
        }
		return false;
        }
    
    /**Return the number of digits in d*/
    private static int getSize(long d) 
    {
        int count = 0;
        while (d > 0) 
        {
            d = d / 10;
            count++;
        }
        return count;
    }
    /**Return the first k number of digits from number. If the
	 * number of digits in number is less than k, return number.*/
    private static long getPrefix(long number, int k) 
    {
        if (getSize(number) < k) 
        {
            return number;
        } 
        else 
        {
            int size = (int) getSize(number);
            for (int i = 0; i < (size - k); i++) 
            {
                number = number / 10;
            }
            return number;
        }
    }   
}


Was This Post Helpful? 0
  • +
  • -

#14 Guille  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 20
  • Joined: 21-October 12

Re: Credit Card Validation, User warnings(few/many-digits. )

Posted 10 March 2013 - 10:59 PM

ok, i figure what was wrong.. all i had to do was add else statements if from of the existing if statements and pass both parameters of the prefixMatched() method as cardNumber, and 1.
thank you again
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1