Create a class with a method that accepts a charge card account number as its argument. The method should determine whether the number is valid by comparing it with a list of valid charge card account numbers. The comparison should be accomplished using a search. If the account number to be checked is in the list of valid account numbers, the method should return true and if the number is not in the list, the method should return false.
The valid account numbers are stored in a file named valid_accounts.txt. A copy of this file should have accompanied this exam. You should create a method that will read the valid charge card account number list and return an array or arrayList object with the 7 digit integer values stored in the file (none of the numbers start with the digit zero).
The account numbers to be checked are stored in a file named accounts_to_check.txt. A copy of this file should have accompanied this exam. You should use the same method as above that will read the charge card account number list and return an array or arrayList object with the 7 digit integer values stored in the file (none of the numbers start with the digit zero).
You should also create a method that takes an array or arrayList object, arranges the charge card account numbers in ascending order and returns the sorted array or ArrayList object.
Demonstrate your class methods in a driver program by reading the charge card account numbers to be checked for validity from a file named accounts_to_check.txt, testing to see if each number that is in the file is valid, and displaying the result of that check in a report. Consider your output a report that someone could easily verify against a sorted valid accounts list. Output two additional reports: A sorted valid accounts list and a sorted accounts to check list.
If you use an ArrayList, you will have to do some independent research to accomplish this solution. Be sure to document any classes or methods you use outside the scope of chapters 1-8 in the book.
The files valid_accounts.txt and accounts_to_check.txt accompany this Final Exam document.
Charge accounts in Java are examined.