Question: Credit card numbers adhere to certain constraints. First, a valid credit card number must have between 13 and 16 digits. Second, it must start with
Credit card numbers adhere to certain constraints. First, a valid credit card number must have between 13 and 16 digits. Second, it must start with one of a fixed number of valid prefixes : 1 4 for Visa 5 for MasterCard 37 for American Express 6 for Discover cards In 1954, Hans Peter Luhn of IBM proposed a checksum algorithm for validating credit card numbers . 2 The algorithm is useful to determine whether a card number is entered correctly or whether a credit card is scanned correctly by a scanner. Credit card numbers are generated following this validity check, commonly known as the Luhn check or the Mod 10 check, which can be described as follows (for illustration, consider the card number 4388576018402626):
* Returns true if the supplied argument * contains only numeric digits (0-9) * * @param s input string * @return true if input contains only numeric digits */ public static boolean isOnlyNumbers(String s) {
//replace with your own code
I need help writing this class of code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
