Checks to see if the cc number is a valid Master Card number @param cc a string representing a credit card number; Sample number: 5500 0000 0000 0004(16 digits) @return true, if the credit card number is a valid MasterCard number, false otherwise
(String cc)
| 915 | * @return true, if the credit card number is a valid MasterCard number, false otherwise |
| 916 | */ |
| 917 | public static boolean isMasterCard(String cc) { |
| 918 | int firstdig = Integer.parseInt(cc.substring(0, 1)); |
| 919 | int seconddig = Integer.parseInt(cc.substring(1, 2)); |
| 920 | |
| 921 | if ((cc.length() == 16) && (firstdig == 5) && ((seconddig >= 1) && (seconddig <= 5))) |
| 922 | return isCreditCard(cc); |
| 923 | return false; |
| 924 | |
| 925 | } |
| 926 | |
| 927 | /** Checks to see if the cc number is a valid American Express number |
| 928 | * @param cc - a string representing a credit card number; Sample number: 340000000000009(15 digits) |
no test coverage detected