Hi I am very new to c++ programming and I was wondering if anyone could help me with a task I have been given. I have been given the template for a credit card validation program and I am unsure as to what I need to put into the bool function of the program. Any help is much appreciated.
review your requirements.
you need to perform the tests, and return whether the number is valid or not.
something like this
bool validateCardNumer(const string number input) //number be a terribad name for a string.
{ int reverseNumer[15]; //what is this? Looks useless.
bool cardStatus = true; //changed for simplicity of logic it was wrong
int evenCount = 0, oddCount = 0, calculatedCheckDigit = 0, //don't need to count both evens/odds the other is input.size - the one you know.
checkDigit=0;
for (const char& c : input)
{
oddcount += c&1;
checkDigit = somethingdigitish;
... do all the counting checking and whatnot
}
...
cardStatus &= (oddcout > something); //if it fails some condition make it false..
... etc
return cardStatus; //the final result of your tests.
}
Thanks for your help but those aspects that you have crossed out are apart of the template that I have been given. The parts that you have stated after the dots are the parts that I'm unsure on how to do.
post the full text. did they not tell you what the tests for the assignment ARE?
they will all look similar to the example I gave above .. loop, do something, evaluate if it is true or false, combine that in your final result.
the crossed out excess variables can be left in, but they are just unused variables most likely. you can use the name number, but it is poorly named.