# Thread: I need help with this last project! Credit Card Program!

1. ## I need help with this last project! Credit Card Program!

the account number to be validated.

Once again, I am no longer trying to get a degree in this field but I really need to pass the class. Help would be very generous!

2. What have you tried and what are you having trouble with?

3. Num = ccnum

Count = 0

While num > 0

Count++

Digit = num % 10 // get last digit

If count % 2 == 1

Total += digit

Else

Digit2 = digit * 2 //Preserve the value of digit

If digit2 > 9

Digit2 = 1 + digit2 % 10
end if

total += digit2

end if

Num /=10 // strips off last digit

End while

If digit = 6

Type = “Discover”

Else if digit = 5

Type = “Mastercard”

Else if digit = 4

Type = “Visa”

Else

Type = “Unknown”

If total % 10 = 0

Card is valid

4. Ok. Write that in C++, and make sure to indent it.

5. Code:
```Num = ccnum

Count = 0

While num > 0

Count++

Digit = num % 10    // get last digit

If count % 2 == 1

Total += digit

Else

Digit2 = digit * 2   //Preserve the value of digit

If digit2 > 9

Digit2 =  1 + digit2 % 10
end if

total += digit2

end if

Num /=10        // strips off last digit

End while

If digit = 6

Type = “Discover”

Else if digit = 5

Type = “Mastercard”

Else if digit = 4

Type = “Visa”

Else

Type = “Unknown”

If total % 10 = 0

Card is valid```

6. Alright, some indentation, and code tags are a good start. Now you just have to change from pseudocode to C++.

7. Can anyone help me with changing it to C++? I really have no idea.

8. Could someone please just help me? Even to get started

9. What have you done so far. It's no point in someone here giving you advice on something you already have done, neither does it help to give advice on what you absolutely don't understand because you haven't got that far.

--
Mats

10. I have done the pseuocode but I need it in C++, Im not trying to learn C++, I had a class on it but I decided programming is not for me so I changed but I still need to pass it and its very challenging, I just need this in C++.

11. So you need to translate your pseudo-code to C++, and you have ABSOLUTELY NO IDEA how to go about that, is that what you are saying?

Did you look at the links by robwhit?

--
Mats

12. He wants someone with the skill and generosity to do the code for him 'cause he doesn't want to learn C++ and he has to finish that thing for school. Or that's how I understand it :P

13. Originally Posted by Akkernight
He wants someone with the skill and generosity to do the code for him 'cause he doesn't want to learn C++ and he has to finish that thing for school. Or that's how I understand it :P
I think you are right. I just wanted to get the original poster to say that...

--
Mats