For the following codes, define the validation criteria (there may be multiple checks for each field) and the order that you would test each of the conditions.

a. A credit card number entered on a Web form: the customer has selected the type of credit card from a drop-down list.
b. A part number in a hardware store: The part number is a complex code, where the first digit represents the department (such as housewares, automotive, and so on), and the number should be self-checking. There are seven different departments.
c. The date that a book was postmarked when returned to an online bookstore: A copy of the customer receipt must be included with the book. Returned books must be postmarked within 30 days of the purchase date.
d. A language spoken code used on a website: Hint: search the Web for standard language codes.
e. A driver’s license number composed of several parts: The person’s birth month, the birthday, and birth year, not necessarily together; a code representing eye color; and a sequence number. The driver’s license contains the date of birth, the eye and hair color, as well as the person’s name and address.
f. The Canadian postal code: the format is X9X 9X9 (X is any letter, 9 is any number).
g. Airline luggage codes: such as L A X for Los Angeles or D U B for Dublin.
h. A product key used to unlock purchased software: The key consists of four groups of five characters each. The first group must have two letters followed by three numbers; the second group must contain two numbers followed by three letters; the third group must contain two letters, each from A through G followed by three numbers from one through four; and the last group must contain a letter, either an E, G, or C, two digits with values from four through seven and two letters, either an A, B, or C. Hint: a pattern may be the best way to validate the product key.

a. Check the credit card number to see if it contains all numeric digits. Check the length of the credit card number using the selected card to determine the number of digits that are required. Use the Luhn formula, with the drop-down list value containing the starting numbers for the card.
b. Check the number to see if it is numeric, and that the first digit represents a correct department. When the number is created, add a check digit. When validating, check to see if the check digit for the number is correct.
c. Store the date as part of the code used to identify the book. When the book is returned, check to see if the postmarked date that the book is returned is less than or equal to 30 days plus the date stored in the transaction code included on the copy of the customer receipt.
d. Language codes must be three digits long, and alphabetic. Search a table of codes to see if the code entered matches one of the valid codes.
e. Check to see if the driver’s license is the correct length and a number, and that the date of birth is the correct length and a number. Check to see if the eye color is entered and has a value stored in a list of valid colors. Then check the digits representing the month, day, and year for the date of birth against the values stored in the date of birth field on the card. Check to see if the code for the eye color has a value that matches the eye color entered on the card.
f. Check to see if the postal code is six characters long, then use a regular expression to validate the code.
g. Check to see if the length is three characters, alphabetic, and matches one of the valid airport codes stored in a table of codes.
h. Check the length of the product code then use a regular expression to validate the values.

Computer Science & Information Technology

You might also like to view...

Double-clicking a tab marker on the ruler will ________

A) insert a leader B) open the Tabs dialog box C) delete the tab marker D) change the tab marker

Computer Science & Information Technology

Why can't a binary search be used on the list as it appears in the accompanying figure?

A. Because the list is too big B. Because the list is not sorted C. Because it is a list of integers D. A binary search can be used on the list

Computer Science & Information Technology