Question: The first function you will write should be called cardType. Your function should take one (1) argument: a string. The string should contain a credit

The first function you will write should be called cardType. Your function should take one (1) argument: a string. The string should contain a credit card number. The function should return one (1) string containing one of the following five (5) values: Visa, MasterCard, Discover Card, Unknown, or Invalid. Your function should ensure that the string contains a valid card number. A valid card number contains ONLY numeric digits (0 9). Additionally, a valid card number has exactly sixteen (16) digits. If the input argument is not a valid card number, your function should return Invalid. Assuming the input argument contains a valid card number, the function should return Visa if the first digit is a 4; return MasterCard if the first digit is a 5; return Discover Card if the first digit is a 6; and return Unknown if the card number starts with anything other number. Example Test Case: cardType(2845682912345) returns Invalid cardType(4124836490234794) returns Visa

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!