This is very ugly to look at, but I am having an issue with my array code. What I am trying to do here is add a name element to my Account accounts[]. When I initiate my driver and I pick the create account option, I am getting the output:
*** MENU *************
*1. Create Account *
*2. Login Account *
*3. Exit ATM *
*====================*
*Enter choice (1-3): *
**********************
1
You chose 1
Enter account holder name:
You must enter in a Name:
Enter account holder name:
What I am trying to figure out is, why can't I get my 1st if statement to work and why it skips the 1st if statement all together.
Some values of note are:
private Account[] accounts;
private static final int ACTKEY = 1000;
private static final int MAXACCT = 100;
private static final double Z = 0.0;
private static final double FEE = 1.50;
private static final long ACTNUMIN = 0;
public String owner;
public double amount = 0.0;
public double fee = 0.0;
public int numAct =0;
public long accountIn =0;
public long account =0;
private void createAccount()
{
// System.out.println(numAct); //place holder
// System.out.println("Enter account holder name: ");
// owner = scan.next();
for (int i = 0; i < numAct; i++)
while(! done)
{
System.out.println("Enter account holder name: ");
owner = scan.nextLine();
if (owner.length() == 0)
{
System.out.println("You must enter in a Name: ");
System.out.println("Enter account holder name: ");
owner = scan.next();
}
else if (i == numAct)
{
System.out.println("Error: Accounts Full. You cannot create another account.");
}
else
{
account = ACTKEY + i;
System.out.println(owner + ", your account number is: " + account);
i++;
}// End of else
//accounts(owner, account, initial);
done = true;
}// End of while loop