For my programming class, we have to design a bank account that reads and writes information to a file, which contains information, such as the 10-digit account number, first and last name, middle initial, and balance for people who open accounts. (So it will say that John A. Smith has an account with number 1234567890 and a balance of at least 26.00) Anyway, I'm having trouble programming it to read and write to the file. This is the instructions regarding reading from the file:
"1. When your program begins running, if the file acinfo.dbf exists, it reads data from it and creates objects of the BankAccount class which are then stored in an array list. acinfo.dbf consists of the fields account number, first name, middle initial, and balance. Your program then closes the file. If the file does not exist, your program simply proceeds since this means that no active account exists. All of this is done in the main method."
I've written this so far, but I have very little clue what I'm doing regarding this, and it may be wrong. :(
public class GeauxBank
{
public static void main(String[] args)
{
ArrayList<BankAccount> accounts = new ArrayList<BankAccount>();
Scanner keyb = new Scanner(System.in);
String acinfo;
System.out.print("What is the input file name?");
acinfo = keyb.next();
Scanner in = null;
try
{
in = new Scanner(new File(acinfo));
}
catch (FileNotFoundException e)
{
}
Can anyone help me figure out what to do?