C++ Help??

Companies that issue credit cards often use algorithms to create credit card numbers that people will have difficulty generating at random. One approach is to add the digits of a number and add 0 or 1 to make the sum of the digits even. For example, the number 45931 (that is, 4+ 5 + 9 + 3 + 1 =22 and is even) would be acceptable, but the number 37230 (that 9s 3 + 7 + 2 +3 = 15 and is odd) would not. The last digit in the number, either a1 or a 0, is called the check digit. Write a program that inputs a four digit number form a text file called Lab1C, , generates the check digit, and displays the original number, check digit number and five-digit credit card number.

Create a text file with the following numbers2347, 4641, 4737, 222, 9998.

I have no idea how to approach this at all.
Last edited on
Welcome to prograaming; the art and craft of thinking about problems in a way that you can then apply the solution using the appropriate programming languages. All the rest is syntax.

Do it on paper first. Then turn each step into code. Here's a way to start:

On Paper:

1) Write down four digit number.
2) Split into four separate integers.
3) Add those four integers.
4) Check to see if that sum is even - if it is, mark down a zero as the "check digit".
If it is not, mark down a one as the "check digit".

Can you carry on?
Topic archived. No new replies allowed.