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

a. The Rochester Bank maintains customer records in a random access file. Write

ID: 3531870 • Letter: A

Question

a. The Rochester Bank maintains customer records in a random access file. Write an application that creates 10,000 blank records and then allows the user to enter customer account information, including an account number that is 9999 or less, a last name, and a balance. Insert each new record into a data file at a location that is equal to the account number. Assume that the user will not enter invalid account numbers. Force each name to eight characters, padding it with spaces or truncating it if necessary. Also assume that the user will not enter a bank balance greater than 99,000.00.

Save the file as CreateBankFile.java.


b. Create an application that uses the file created by the user in Exercise 9a and displays all existing

accounts in account-number order. Save the file as ReadBankAccountsSequentially.java.


c. Create an application that uses the file created by the user in Exercise 9 a and allows the user to enter an account number to view the account balance. Allow the user to view additional account balances until entering an application-terminating value. Save the file as ReadBankAccountsRandomly.java.


Thank you for your help!



Explanation / Answer

import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.RandomAccessFile; public class NationalBank { public static void main(String[] args) { InputStreamReader temp = null; BufferedReader input = null; try { temp = new InputStreamReader(System.in); input = new BufferedReader(temp); int acct; double amount[] = new double[9999]; String name[] = new String[9999]; RandomAccessFile file = new RandomAccessFile("bank.txt", "rw"); while(true) { System.out.println("Enter Account Number (0-9999): "); acct = Integer.parseInt(input.readLine()); System.out.println("Enter Last Name: "); name[acct] = input.readLine(); System.out.println("Enter Balance "); amount[acct] = Double.parseDouble(input.readLine()); if(acct >=0 && acct <=9999) { file.seek(acct*10); file.writeBytes(" "+name[acct]); file.writeBytes(" "+amount[acct]); } System.out.println("Enter More? (y/n)"); if (input.readLine().toLowerCase().equals("n")) break; } file.close(); } catch (Exception e) { } } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote