From essays to dissertations, we have experts for all of your assignments!

dot
  • 1.provide your instructions
  • 2.choose an expert in your field
  • 3.track the order progress

Project 3

Write a PHP program that determines if a given credit card number is a valid Visa, MasterCard, or Discover credit card number
by performing the Luhn check (aka the Mod 10 check).
The format for a valid American Express, Visa, MasterCard, or Discover credit number is as follows:
American Express numbers start with 3
Visa card numbers start with 4
MasterCard numbers start with 5
Discover card numbers with with 6
Visa, MasterCard and Discover card types must have exactly 16 digits
American Express card types must have exactly 15 digits

Given the sample credit card number: 4388576018402626
The algorithm for the Luhn/Mod 10 check is as follows:

Starting from the second digit from right and moving to the left, double every other digit.
If the result from doubling is two digits, then add those two digits together to end up with a one digit number.

Add up all of the one digit numbers from Step 1.

4 + 4 + 8 + 2 + 3 + 1 + 7 + 8 = 37

Starting from the right most digit and moving to the left, sum every other digit.

6 + 6 + 0 + 8 + 0 + 7 + 8 + 3 = 38

Sum the integer results from Step 2 and Step 3.

37 + 38 = 75

If the integer result from Step 4 is evenly divisible by 10 (i.e. there is no remainder),
then the card number is valid; else the card number is invalid.

75 / 10 has a remainder of 5, therefore, this sample credit card number is invalid.

Your program must adhere to the following specifications:

It must have seven (7) functions named exactly as follows:

Function Name
Number of
Parameters
Received
isCCValid
1
checkType
1
checkLength
2
convertCC2Array
1
doubleSumEvenPos
1
sumOddPos
1
sumMod
2

The functions must be formulated as follows:

Function Name
Function
Description
Receiving
Parameter
Description
Receiving
Parameter
Data Type
Returning
Parameter
Data Type
Returning
Parameter
Description
isCCValid
Calls the six functions
Credit Card Number
String
Boolean
Returns true if the credit card number is valid,
otherwise returns false
checkType
Checks the first digit of the Credit Card Number for
validity and returns the Credit Card type
Credit Card Number
String
String
Returns the type of credit card as follows:

“VISA” for Visa
“MCRD” for MasterCard
“DISC” for Discover
“AMEX” for American Express
“INVD” for none of the above; considered Invalid
checkLength
Checks the Credit Card Number length against the
Credit Card type
Credit Card Number
String
Boolean
Returns true if the credit card number length is valid,
otherwise returns false
Credit Card Type – See Returning Parameter
from function checktype
String
convertCC2Array
Converts a Credit Card Number string to an array
Credit Card Number
String
Array
Returns a credit card number as Single Dimension Array
doubleSumEvenPos
Performs the calculations from Steps 1 and 2 above
Credit Card Number (Array) – See Returning
Parameter from function convertCC2Array
Array
Integer
Returns the result of Steps 1 and 2 above
sumOddPos
Performs the calculations from Step 3 above
Credit Card Number (Array)- -See Returning
Parameter from function convertCC2Array
Array
Integer
Returns the result of Step 3 above
sumMod
Performs the calculations from Steps 4 and 5 above
Result returned from function doubleSumEvenPos
Integer
Boolean
Returns true if the result of the Mod10 check
is valid, otherwise returns false
Result returned from function sumOddPos
Integer

DO NOT send me any programs that contain any credit card numbers.
Your credit card variable should be equated to “” in the program that you submit.
I will generate my own test data to evaluate and grade your program.
You must use this code for the Main part of your program.
    if (isCCValid($creditCardNumber))
        echo $creditCardNumber . ” is valid.”;
    else
        echo $creditCardNumber . ” is not valid.”;

Function isCCValid must call the other six functions.
Set variable $creditCardNumber to some credit card number in your the Main part of your program
in order to test. You may use the following test data or make up your own.
These credit card numbers are not real but they will pass the Luhn/Mod 10 check:
For Visa, $creditCardNumber = “4111111111111111”;
For MasterCard, $creditCardNumber = “5212121212121211”;
For Amex, $creditCardNumber = “311111110101010”;
For Discover, $creditCardNumber = “6111111212121212”;

This is an invalid credit card number that you can use to test (or make up your own), $creditCardNumber = “4388576018402626”;
Programs that do not follow the above assignment specifications (as summarized in this list) will receive a heavy reduction in the score:
Main part of the program matches the given code above
Number of functions
Function names
Function perform tasks as described
Function receiving parameters – correct number of parameters and data types
Function returning parameters – data

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes