Answered step by step
Verified Expert Solution
Question
1 Approved Answer
using java Write a program that reads from a list of credit cards and determines if those cards are valid. Each file provided encodes the
using java
credit-cards-1.dat Required Output Enter a filename in Credit card number: 3782 8224 6310 005 Checksum: 600 Card status: VALID Credit card number: 3714 4963 5398 431 Checksum: 80 Card status: VALIDIIN Credit card number: 3787 3449 9671 000n Checksum: 66 Card status: INVALIDIN Credit card number: 5610 5990 8101 8250 Checksum: 47 Card status: INVALID Credit card number: 3096 9309 0259 04 Checksum: 58 Card status: INVALID Credit card number: 3852 0009 8232 37 In Checksum: 56 Card status: INVALID Credit card number: 3787 3449 3671 000 Checksum: 60n Card status: VALID Credit card number: 5610 5910 8101 1250 Checksum: 35 in Card status: INVALID Credit card number: 3056 9309 0259 84n Checksum: 50 kn Card status: VALID IN Credit card number: 3852 0000 0232 37 in Checksum: 40 in Card status: VALID In Credit card number: 6011 1111 1111 1117 Checksum: 30 Card status: VALID Write a program that reads from a list of credit cards and determines if those cards are valid. Each file provided encodes the credit card numbers are longs. In binary, read each long and process the card.
To determine if a credit card is valid, use the following algorithm.
From the rightmost digit, which is the check digit, and moving left, double the value of every second digit. The check digit is not doubled; the first digit doubled is immediately to the left of the check digit. If the result of this doubling operation is greater than 9 (e.g., 8 2 = 16), then add the digits of the result (e.g., 16: 1 + 6 = 7, 18: 1 + 8 = 9) or, alternatively, the same final result can be found by subtracting 9 from that result (e.g., 16: 16 9 = 7, 18: 18 9 = 9).
Take the sum of all the digits. (Display this to the user)
If the total modulo 10 is equal to 0 (if the total ends in zero) then the number is valid.
please format as in the required picture below thank you
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