instructions program Credit Card Validator - Takes in a credit card number from a common credit card vendor (Visa, MasterCard, American Express, Discover) and validates it to make sure that it is a...



instructions



program Credit Card Validator
- Takes in a credit card number from a common credit card vendor (Visa, MasterCard, American Express, Discover) and validates it to make sure that it is a valid number (look into how credit cards use a checksum)



//what I need


As you can see from the instruction, I have incomplete code and I want you to correct something or add something in the code to get the output that is required in the instructions. And just to remind you the code is incomplete. here is my code.




#include

#include

#include



using namespace std;





void printCN(string cardCN,int size);








int main()

{

string cardInput = "";

constint size = 16; // Number of digits the card number have

int card[size]; //This array stores card number



int sum = 0;

int oddSum = 0, evenSum;

cout < "enter="" credit="" card="" number:="">

cin >> cardInput;



for (int counter = 0; counter < cardinput.size();="" counter++)="" card[counter]="cardInput[counter]-">



//Luhn Alogrithm

for (int counter = size - 1; counter >=0; counter--)

{

int placeholder;

int x = card[counter];



if (counter % 2 ==0)

{

placeholder = x * 2;

if (placeholder > 9) placeholder = placeholder - 9;

evenSum += placeholder;



}

else

{

placeholder = x;

oddSum += placeholder;

}



}



sum = evenSum + oddSum;



cout < "even="" sum="" is="" :="" "=""><>

cout < "="" \n="" odd="" sum="" is="" :="" "=""><>

cout < "\n="" total="" sum="" is="" :="" "="">< sum=""><>




if (sum % 10 == 0) {

cout <>

printCN(cardInput, size);

cout < "card="" is="">

}

else {

cout <>

printCN(cardInput, size);

cout < "card="" is="">

}







//4000000000002829

//4000001234567899







return EXIT_SUCCESS;

}





void printCN(string cardInput, int size)

{

if (cardInput[0]=='4')

{

cout < "="" visa="">

}



elseif (cardInput[0] == '6')

{

cout < "="" master="">



}



else

{

cout < "="" unknown="" brand="">

}



}




Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here