I need to write a Java program that validates credit card numbers, and to do that I need to preform operations on each individual digit. How can I get these digits, without using strings or arrays?
int number; (This would be your credit card number)
while (number > 0) {
System.out.println( number % 10);
number = number / 10;
}
This will print them in reverse order. You can perform your operations on the digits this way.