Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

here is the credit card numbers to evaluate Data to Evaluate 3158539628375348 33

ID: 3760206 • Letter: H

Question

here is the credit card numbers to evaluate

Data to Evaluate
3158539628375348
3337465828248404
3112804683572030
3112804683572033
5435528978467581
6706465468107999
6304362971054667
6706169762827894
6706169762827892
4844104341377697
4913405490886727
4844885754351829
4844885754351822
6371473570875275
6381475006869978
6389057917814806
347100734345549
347100734345543
6011162533805000
6011621663574413
6011824617460743
6011824617460745
6389057917814802
4539318768050385
36880982786892
36845793345501
36661154562232
36661154562234
5893329089846994
6761680165952016
6763100400984029
6763100400984022
5127043299122389
5330838017737340
5429168755154025
5429168755154023
375354034606481
379570632133224
4485521241443135
4532916206508075
4532916206508076
5590976687287124
5540641137519895
5540641137519892
30522070708059
30066552673241
30365487186802
30365487186801

here is how to organize the numbers

VISA:
45
44
MasterCard:
51
53
American Express (AMEX):
37
34
Discover:
60
JCB:
31
33
Diners Club - North America:
54
55
Diners Club - Carte Blanche:
30
Diners Club - International:
36
Maestro:
58
LASER:
67
Visa Electron:
48
49
InstaPayment:
63

Your task is to: Read the data listed below ''Data to Evaluate'' from a file. Evaluate each number to see if they are representing a possible credit card number. Validate each credit card number to see if they are a valid number. Store the valid numbers and invalid numbers in a separate array. Write the contents of validated credit card number array into a file called ''valid_cards.txt''. Write the invalid credit card number array to a file called ''invalid_numbers.txt''. Make sure to include the issuer for each group of credit card numbers identified. Your application should work with any number of credit card entries.

Explanation / Answer

import java.io.File;

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Test {

public static void main(String args[]) {
//arrays declared
int[] arr = {45,44,51,53,37,34,60,31,33,54,55,30,36,58,67,48,49,63};
ArrayList validate = new ArrayList();
ArrayList invalidate = new ArrayList();
//reading file
File file = new File("dataToEvaluate.txt");
File valid = new File("validCards.txt");
File invalid = new File("invalid_numbers.txt");
try {
Scanner sc = new Scanner(file);
//parsing each integer
while (sc.hasNextLine()) {
int i = sc.nextInt();
int temp = 0;
//checking for valid number or not
int twoDigit = Integer.parseInt(Integer.toString(i).substring(0, 2));
for(int j=0;j<18;i++){
if(twoDigit == arr[j]){
temp++;
break;
}
}
//storing into respective arrays
if(temp == 0){
invalidate.add(i);
}
else{
validate.add(i);
}
temp=0;
}
  
//writing results back to
PrintWriter validnumbers = new PrintWriter(valid);
PrintWriter invalidNumbers = new PrintWriter(invalid);
for(int i=0;i<validate.size();i++){
validnumbers.write((int) validate.get(i));
}
  
for(int i=0;i<invalidate.size();i++){
invalidNumbers.write((int) invalidate.get(i));
}
  
sc.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}