Question: USE JAVA Problem 2. (20 points) Credit Card Number Validation: In this problem, your job is to validate a credit card number given by the

USE JAVA

USE JAVA Problem 2. (20 points) Credit Card Number Validation: In this

Problem 2. (20 points) Credit Card Number Validation: In this problem, your job is to validate a credit card number given by the user as a String. First, remove all the spaces or dashes between the number. (Remember that the number is given as a string.) Then, do the following steps to validate the number: Form the sum of all the digits of the credit card number. Add to that sum every second digit, starting with the second digit from the right. Add the number of digits in the second step that are greater than 4. The result should be divisible by 10. . * . For example, consider the number 4012 8888 8888 1881.The sum of all digits is 89. The sum of the colored digits is 46. There are five colored digits larger than 4, so the result is 89+46+5-140. This final number, 140 is divisible by 10, so the card number is valid. Write a Java program, to create a class for this problem, including a method to check the validity of a given number. Then, write a tester program to test some 16-digits numbers for their validity to be credit card numbers

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!