[You may use arrays]
Credit Card Number Validation
Payment card usage in Egypt is on a steady rise. According to the CBE report there are over 22 million active
debit and credit cards in Egypt. This means that vendors accepting payments through these cards need to
have a way of validating the card numbers before attempting to process the payment.
Luckily there is a systematic way to validate card numbers.

  1. First verify the number of digits is valid (between 14 and 16)
  2. Starting from the right multiply each second digit by 2. If the result of the multiplication is more than
    1 digit add the digits together until you have a single digit.
  3. Sum the digits from the previous step.
  4. Sum the digits that had not been multiplied by 2 in step 2
  5. Add the results from step 3 and 4 together
  6. If the result is divisible by 10 then the number is valid
    Write a program that takes a credit card number as input and checks its validity.
    • Implement and make use of the following functions:
    o A function that takes a card number and returns its validity (true/false)
    o A function that takes a card number and calculates the sum described in points 2 & 3 above.
    o A function that takes a card number and calculates the sum described in point 4 above.
    o A function that takes an integer and returns it as it is if it’s a single digit, otherwise it returns
    the sum of the 2 digits.

Recommended Answers

All 4 Replies

// I cannot continue if any one here can help
#include <iostream>
using namespace std;
int main()

int x;
string names;
cout<<"enter number of voters \n";
cin>>x;
cout<<"enter names of candidates \n ";
 cin >> names;
  if (names == "Adham:Bilal:Catherine")
      cout << " in new system adham get 3 point,Bilal get 2,Catherine get 1 \n ";
       cout<<  " in old system adham get 1 point,Bilal get 0,Catherine get 0\n";


  if (names == "Adham:Catherine:Bilal")
      cout << " in new system Adham get 3 point,Catherine  get 2,Bilal get 1 \n ";
       cout<< "and in old system Adham get 1 point,Catherine get 0,Bilal get 0\n";

  if (names == "Bilal:Catherine:Adham")
      cout << " in new system get Bilal 3 point,Catherine  get 2,Adham get 1 \n ";
       cout<< "and in old system Bilal get 1 point,Catherine get 0,Bilal get 0\n";

  if (names == "Bilal:Adham:Catherine")
      cout << " in new system get Bilal 3 point,Adham get 2,Catherine get 1 \n ";
       cout<< "and in old system Bilal get 1 point,Adham get 0,Catherine get 0\n";

  if (names == "Catherine:Adham:Bilal")
      cout << " in new system Catherine get 3 point,Adham get 2, Bilal 1 \n ";
        cout<< "and in old system Catherine get 1 point,Adham get 0,Bilal get 0\n";

  if (names == "Catherine:Bilal:Adham")
      cout << " in new system Catherine get 3 point,Bilal get 2, Adham 1 \n ";
        cout<< "and in old system Catherine get 1 point,Bilal get 0,Adham get 0\n";

return 0;

Your second post in this thread doesn't look like credit card code. Looks like voting code. Mistake?

commented: yes your are right i post wrong qestion +0

I'd decide if you want to write some voting code or look at the link I gave. Remember I take it this is a real request from you and not another homework assignment. For homework you share where you are stuck.

commented: ok thank you +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.