Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You're starting your own credit card business. You've come up with a new way to validate credit cards with a simple function called validateCreditCard that

You're starting your own credit card business. You've come up with a new way to validate credit cards with a simple function called validateCreditCard that returns true or false.

Here are the rules for a valid number:

Number must be 16 digits, all of them must be numbers

You must have at least two different digits represented (all of the digits cannot be the same)

The final digit must be even

The sum of all the digits must be greater than 16

The following credit card numbers are valid:

9999-9999-8888-0000

6666-6666-6666-1666

The following credit card numbers are invalid:

a923-3211-9c01-1112 invalid characters

4444-4444-4444-4444 only one type of number

1111-1111-1111-1110 sum less than 16

6666-6666-6666-6661 odd final number

You will need to create a web form that allows your users to enter credit card numbers and on change, validate if the credit card is valid and display a message to the user accordingly.

Hint: Remove the dashes from the input string before checking if the input credit card number is valid. (check out split() and join() methods.

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

Students also viewed these Databases questions

Question

2. What process will you put in place to address conflicts?

Answered: 1 week ago