Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started