Write a Java program that gives a financial report. This program should give the user the following options:
compare a check register (the file register.txt) against a bank statement (the file statement.txt), and report any discrepancies;
print out all transactions for a given location, using the bank statement;
quit.
Codes for transaction types are as follows: 1 - Debit, 2 - Credit.
Codes for locations are as follows: 1 - Grocery, 2 - Store, 3 - School, 4 - Bank.
The format of both register.txt and statement.txt are the same. There is one transaction per line and is represented in the following order:
transaction number (int), amount(double), transaction type(int), transaction location(int).
When you print out dollar amounts, you must print the $ sign, the period and 2 decimal places, as is normal for dollar amounts. So the amount 500 would print as $500.00. Also, assume that statement.txt has transactions ordered by transaction number (101, 102, 103, etc.)
Note: For this assignment you may assume, somewhat unrealistically, that the two files have the same transaction numbers and in the same order.
Descrepancies between the register.txt file and the statement.txt file may occur, but only in the amounts.
For testing purposes, a sample statement.txt and register.txt are provided.
public static int menu() - prints out the menu choices to the user, and returns the user's selection
public static void compare() - opens register.txt and statement.txt and compares transaction numbers and amounts to determine if there are any discrepancies between the check register and the bank statement. It prints out the discrepancies when they occur. If no discrepancies occur, a message should print out saying no discrepancies.
Hints: You will need to open and close the files in this and other functions.
public static void printByLocation() - prompt for a location [1 - 4] , open the file statement.txt and print to the screen the transaction number, amount, and the transaction type for all transactions that match the input location.
public static void printAll() - prints out each transaction (number, amount, type, and location) from statement.txt, one per line to the screen.
public static String getTransLocation(int) - given a transaction location code, return the following: "Grocery" if the location code is 1; "Store" if the location code is 2; "School" if the location code is 3; "Bank" if the location code is 4
public static String getTransType(int) - given a transaction type, return the following: "Debit" if the type is 1; "Credit" if the type is 2.
You may create and use other functions as you see the need, but the above functions must be included.
glenn: java Report Welcome to Check Register Reconciliation 1. Compare check register with bank statment. 2. Print transactions for a given location. 3. Print all transactions. 4. Quit. > 3 Transaction Amount Type Location 501 $ 33.78 Debit School 502 $ 160.00 Debit Bank 503 $ 260.47 Credit Bank 504 $ 9.50 Debit Store 507 $ 39.99 Debit Store 510 $ 75.10 Debit Grocery 1. Compare check register with bank statment. 2. Print transactions for a given location. 3. Print all transactions. 4. Quit. >
1. Compare check register with bank statment. 2. Print transactions for a given location. 3. Print all transactions. 4. Quit. > 2 Which location [1-4]: 2 Transaction Amount Type Location 504 $ 9.50 Debit Store 507 $ 39.99 Debit Store 1. Compare check register with bank statment. 2. Print transactions for a given location. 3. Print all transactions. 4. Quit. >
1. Compare check register with bank statment. 2. Print transactions for a given location. 3. Print all transactions. 4. Quit. > 1 Conflict on transaction number 503 Bank statement amount: $260.47 Your register amount: $260.48 Conflict on transaction number 510 Bank statement amount: $75.10 Your register amount: $75.00 1. Compare check register with bank statment. 2. Print transactions for a given location. 3. Print all transactions. 4. Quit. >
Welcome to Check Register Reconciliation 1. Compare check register with bank statment. 2. Print transactions for a given location. 3. Print all transactions. 4. Quit. > 1 No conflicts! 1. Compare check register with bank statment. 2. Print transactions for a given location. 3. Print all transactions. 4. Quit. >