private int calcCheckDigits() {
int sum;
sum = checkSum();
System.out.println("Sum2 = " + sum);
// if ((sum + checkDigit) % 10 == 0) {
checkDigit += sum;
...
Type: Posts; User: hotshotennis
private int calcCheckDigits() {
int sum;
sum = checkSum();
System.out.println("Sum2 = " + sum);
// if ((sum + checkDigit) % 10 == 0) {
checkDigit += sum;
...
I think it assigns a value, just not the right one because sum is completely off and too large... But I don't know where the logic in the code is wrong.
checkDigit is assigned inside of the method calcCheckDigits. But it relies on sum, which I'm pretty sure is wrong.
If I assign chechDigit to -1 like you specified, the new output I get looks like...
Okay here is my new scanner definition:
static Scanner scanner = new Scanner("321321\n654654654\n2\n987987\nn");
And my resulting output from it(still has the debugging println for sum):...
My debugging println statement was used to print out the sum right before it is returned from the method chechSum. I provided the user input used in running the program in my very first post. Here it...
Hmmm its made from my checkSum method.... but I cannot understand how my sum could end up being zero. Everything looks good to me. I guess I'll try tinkering with it some more.
--- Update ---
...
public class CreditCardNumber {
private String issuerID = "000000";
private String accountNum = "999999999";
private int checkDigit;
public CreditCardNumber(String tempIssuerID, String...