I already tried this:
public static void accountTypeSavings() {
boolean b = true;
while (b) {
String startBalanceString = JOptionPane.showInputDialog(null, "Enter the starting balance in dollars without the dollar sign.");
try {
double startBalance = Double.parseDouble(startBalanceString);
int accountID = 1;
SavingsAccount accountID = new SavingsAccount(holder, startBalance);
accountID += 1;
b = false;
}
catch (final Exception ignored) {
JOptionPane.showMessageDialog(null, "Only enter numbers, please.");
}
}
}
Creating an integer and setting the name of the savings account to the integer. But that's giving me the error "Duplicate local variable accountID".
When using my application, I want to get this:
SavingsAccount sa1 = new SavingsAccount(holder, startBalance);
SavingsAccount sa2 = new SavingsAccount(holder, startBalance);
SavingsAccount sa3 = new SavingsAccount(holder, startBalance);
The parameters are variables whose are already initialized!
I want to set the name of the new SavingsAccount to the accountID's value. So if I create a new instance of a SavingsAccount, I want my application to set it's name to sa1. And if I create another one after that, name it sa2, sa3, sa4, etc.
PS: Holder is a string, it contains the name of someone! It's not an integer!
I hope you understand what I mean!