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!
Printable View
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!
What have you tried and what are you having trouble with?
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
Ok. Write that in C++, and make sure to indent it.
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
Alright, some indentation, and code tags are a good start. Now you just have to change from pseudocode to C++.
Can anyone help me with changing it to C++? I really have no idea.
Could someone please just help me? Even to get started
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
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++.
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
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
http://cboard.cprogramming.com/annou...t.php?f=3&a=39
^ Link for the topicstarter :p