Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program is written in Java and it varifies credit cards Constraints Credit card must be 16 digits in length Credit card format must be ####-####-####-####

Program is written in Java and it varifies credit cards

Constraints

Credit card must be 16 digits in length

Credit card format must be ####-####-####-#### or ################

.Expiration must be in the form: MM/YY

Notify user of correct entry form for CC# and Exp

Name, CC#, and Exp must be entered as Strings

Use a separate (external to the main class) subclass, VerifyCard() to validate the CC# with the following private method conditions:

o Condition 1: The first digit must be a 4 o Condition 2: The fourth digit must be one greater than the fifth digit o Condition 3: The product of the first, fifth, and ninth digits must be 24 o Condition 4: The sum of all digits must be evenly divisible by 4 o Condition 5: The sum of the four digits in the expiration date must be less than the product of the last two digits of the card number o Condition 6: The sum of the first four digits must be one less than the sum of the last four digits o Condition 7: If you treat the first two digits as a two-digit number, and the 15th and 16th digits as a two digit number, their sum must be 100 (Example: 4643262531465454 -> 46 + 54 = 100)

Requirements

Ask the user for the credit card holder name

Ask the user for the credit card number

Ask the user for the expiration date

Use set and get methods in the subclass for the information entered by the user

Set methods must be private

All Condition listed in Constraints should be private methods

Use a regex String for Condition 1

Most Condition methods will use an if statement

Condition methods 4-6 will need one to two for loops to step through the int arrays

Hints

CC# and Exp can be converted into int Arrays

The following CC#s can be used as test cases. Each of these numbers will return as valid. Make sure you change them around or enter other CC#s that are not valid:

o 4192112566331259

o 4283253533222358

o 4374398522116157

o 4292154566732358

o 4553223534333555

o 4643262531465454

o 4732169566119053

o 4823287533234752

Each of the CC#s will work with an Exp of 12/15. By increasing the YY, you may find that a few of these cards will not be valid

Consider using the .replaceAll() method to remove slashes and/or dashes from entered Strings

Consider using the .split() method when converting the Strings to int Arrays

The .parseInt() method and the Integer class can be your friend in this assignment

Expected Output

The sample output below has executed three runs of the program. User input is in red.

Enter Card Holder's Name: Tom Jones Enter Credit Card Number (No dashes): 4553223534333555 Enter Credit Card Expiration Date (MM/YY): 12/15

Card number: 4553223534333555 is a valid credit card.

Run program again? (Y for Yes, N for No): y Enter Card Holder's Name: Dean Martin Enter Credit Card Number (No dashes): 4732169566119053 Enter Credit Card Expiration Date (MM/YY): 12/15

Card number: 4732169566119053 is a valid credit card.

Run program again? (Y for Yes, N for No): Y Enter Card Holder's Name: Frank Sinatra Enter Credit Card Number (No dashes): 4234253533211358 Enter Credit Card Expiration Date (MM/YY): 12/15

Card number: 4234253533211358 is NOT a valid credit card.

Run program again? (Y for Yes, N for No): n Thank you. Goodbye!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

E Z Accounting

Authors: Peter Eisen

5th Edition

0764142569, 978-0764142567

Students also viewed these Databases questions